Skip to content

Commit 117ea1f

Browse files
committed
Rename use_tokio feature async-tokio
1 parent 2fe3b32 commit 117ea1f

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Changed
66

7+
- [breaking-change] Renamed `use_tokio` feature `async-tokio`.
78
- Migrated to 'tokio' crate.
89
- Updated `nix` to version 0.22.
910
- Minimmum supported Rust version updated to 1.46.0.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ readme = "README.md"
1111

1212
[features]
1313
mio-evented = ["mio"]
14-
use_tokio = ["futures", "tokio", "mio-evented"]
14+
async-tokio = ["futures", "tokio", "mio-evented"]
1515

1616
[dependencies]
1717
futures = { version = "0.1", optional = true }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The following features are planned for the library:
8282
- [x] Support for configuring interrupts on GPIO
8383
- [x] Support for polling on GPIO with configured interrupt
8484
- [x] Support for asynchronous polling using `mio` or `tokio` (requires
85-
enabling the `mio-evented` or `use_tokio` crate features, respectively)
85+
enabling the `mio-evented` or `async-tokio` crate features, respectively)
8686

8787
## Minimum Supported Rust Version (MSRV)
8888

examples/tokio.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
#[cfg(feature = "use_tokio")]
1+
#[cfg(feature = "async-tokio")]
22
extern crate futures;
3-
#[cfg(feature = "use_tokio")]
3+
#[cfg(feature = "async-tokio")]
44
extern crate sysfs_gpio;
5-
#[cfg(feature = "use_tokio")]
5+
#[cfg(feature = "async-tokio")]
66
extern crate tokio;
77

8-
#[cfg(feature = "use_tokio")]
8+
#[cfg(feature = "async-tokio")]
99
use std::env;
1010

11-
#[cfg(feature = "use_tokio")]
11+
#[cfg(feature = "async-tokio")]
1212
use futures::{lazy, Future, Stream};
1313

14-
#[cfg(feature = "use_tokio")]
14+
#[cfg(feature = "async-tokio")]
1515
use sysfs_gpio::{Direction, Edge, Pin};
1616

17-
#[cfg(feature = "use_tokio")]
17+
#[cfg(feature = "async-tokio")]
1818
fn stream(pin_nums: Vec<u64>) -> sysfs_gpio::Result<()> {
1919
// NOTE: this currently runs forever and as such if
2020
// the app is stopped (Ctrl-C), no cleanup will happen
@@ -44,7 +44,7 @@ fn stream(pin_nums: Vec<u64>) -> sysfs_gpio::Result<()> {
4444
Ok(())
4545
}
4646

47-
#[cfg(feature = "use_tokio")]
47+
#[cfg(feature = "async-tokio")]
4848
fn main() {
4949
let pins: Vec<u64> = env::args()
5050
.skip(1)
@@ -57,7 +57,7 @@ fn main() {
5757
}
5858
}
5959

60-
#[cfg(not(feature = "use_tokio"))]
60+
#[cfg(not(feature = "async-tokio"))]
6161
fn main() {
6262
println!("This example requires the `tokio` feature to be enabled.");
6363
}

src/lib.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,26 @@
4242
//! }
4343
//! ```
4444
45-
#[cfg(feature = "use_tokio")]
45+
#[cfg(feature = "async-tokio")]
4646
extern crate futures;
4747
#[cfg(feature = "mio-evented")]
4848
extern crate mio;
4949
#[cfg(not(target_os = "wasi"))]
5050
extern crate nix;
51-
#[cfg(feature = "use_tokio")]
51+
#[cfg(feature = "async-tokio")]
5252
extern crate tokio;
5353

5454
use std::fs;
5555
use std::fs::File;
5656
use std::io;
5757
use std::io::prelude::*;
58-
#[cfg(any(target_os = "linux", target_os = "android", feature = "use_tokio"))]
58+
#[cfg(any(target_os = "linux", target_os = "android", feature = "async-tokio"))]
5959
use std::io::SeekFrom;
6060
#[cfg(not(target_os = "wasi"))]
6161
use std::os::unix::prelude::*;
6262
use std::path::Path;
6363

64-
#[cfg(feature = "use_tokio")]
64+
#[cfg(feature = "async-tokio")]
6565
use futures::{Async, Poll, Stream};
6666
#[cfg(feature = "mio-evented")]
6767
use mio::unix::EventedFd;
@@ -71,7 +71,7 @@ use mio::Evented;
7171
use nix::sys::epoll::*;
7272
#[cfg(not(target_os = "wasi"))]
7373
use nix::unistd::close;
74-
#[cfg(feature = "use_tokio")]
74+
#[cfg(feature = "async-tokio")]
7575
use tokio::reactor::{Handle, PollEvented};
7676

7777
pub use error::Error;
@@ -126,7 +126,7 @@ fn flush_input_from_file(dev_file: &mut File, max: usize) -> io::Result<usize> {
126126
}
127127

128128
/// Get the pin value from the provided file
129-
#[cfg(any(target_os = "linux", target_os = "android", feature = "use_tokio"))]
129+
#[cfg(any(target_os = "linux", target_os = "android", feature = "async-tokio"))]
130130
fn get_value_from_file(dev_file: &mut File) -> Result<u8> {
131131
let mut s = String::with_capacity(10);
132132
dev_file.seek(SeekFrom::Start(0))?;
@@ -475,8 +475,8 @@ impl Pin {
475475
/// The PinStream object can be used with the `tokio` crate. You should probably call
476476
/// `set_edge()` before using this.
477477
///
478-
/// This method is only available when the `use_tokio` crate feature is enabled.
479-
#[cfg(feature = "use_tokio")]
478+
/// This method is only available when the `async-tokio` crate feature is enabled.
479+
#[cfg(feature = "async-tokio")]
480480
pub fn get_stream_with_handle(&self, handle: &Handle) -> Result<PinStream> {
481481
PinStream::init_with_handle(*self, handle)
482482
}
@@ -486,8 +486,8 @@ impl Pin {
486486
/// The PinStream object can be used with the `tokio` crate. You should probably call
487487
/// `set_edge()` before using this.
488488
///
489-
/// This method is only available when the `use_tokio` crate feature is enabled.
490-
#[cfg(feature = "use_tokio")]
489+
/// This method is only available when the `async-tokio` crate feature is enabled.
490+
#[cfg(feature = "async-tokio")]
491491
pub fn get_stream(&self) -> Result<PinStream> {
492492
PinStream::init(*self)
493493
}
@@ -502,8 +502,8 @@ impl Pin {
502502
/// it could end up producing the same value multiple times if the value has changed back
503503
/// between when the interrupt occurred and when the value was read.
504504
///
505-
/// This method is only available when the `use_tokio` crate feature is enabled.
506-
#[cfg(feature = "use_tokio")]
505+
/// This method is only available when the `async-tokio` crate feature is enabled.
506+
#[cfg(feature = "async-tokio")]
507507
pub fn get_value_stream_with_handle(&self, handle: &Handle) -> Result<PinValueStream> {
508508
Ok(PinValueStream(PinStream::init_with_handle(*self, handle)?))
509509
}
@@ -518,8 +518,8 @@ impl Pin {
518518
/// it could end up producing the same value multiple times if the value has changed back
519519
/// between when the interrupt occurred and when the value was read.
520520
///
521-
/// This method is only available when the `use_tokio` crate feature is enabled.
522-
#[cfg(feature = "use_tokio")]
521+
/// This method is only available when the `async-tokio` crate feature is enabled.
522+
#[cfg(feature = "async-tokio")]
523523
pub fn get_value_stream(&self) -> Result<PinValueStream> {
524524
Ok(PinValueStream(PinStream::init(*self)?))
525525
}
@@ -667,13 +667,13 @@ impl Evented for AsyncPinPoller {
667667
}
668668
}
669669

670-
#[cfg(feature = "use_tokio")]
670+
#[cfg(feature = "async-tokio")]
671671
pub struct PinStream {
672672
evented: PollEvented<AsyncPinPoller>,
673673
skipped_first_event: bool,
674674
}
675675

676-
#[cfg(feature = "use_tokio")]
676+
#[cfg(feature = "async-tokio")]
677677
impl PinStream {
678678
pub fn init_with_handle(pin: Pin, handle: &Handle) -> Result<Self> {
679679
Ok(PinStream {
@@ -683,7 +683,7 @@ impl PinStream {
683683
}
684684
}
685685

686-
#[cfg(feature = "use_tokio")]
686+
#[cfg(feature = "async-tokio")]
687687
impl PinStream {
688688
pub fn init(pin: Pin) -> Result<Self> {
689689
Ok(PinStream {
@@ -693,7 +693,7 @@ impl PinStream {
693693
}
694694
}
695695

696-
#[cfg(feature = "use_tokio")]
696+
#[cfg(feature = "async-tokio")]
697697
impl Stream for PinStream {
698698
type Item = ();
699699
type Error = Error;
@@ -714,18 +714,18 @@ impl Stream for PinStream {
714714
}
715715
}
716716

717-
#[cfg(feature = "use_tokio")]
717+
#[cfg(feature = "async-tokio")]
718718
pub struct PinValueStream(PinStream);
719719

720-
#[cfg(feature = "use_tokio")]
720+
#[cfg(feature = "async-tokio")]
721721
impl PinValueStream {
722722
#[inline]
723723
fn get_value(&mut self) -> Result<u8> {
724724
get_value_from_file(&mut self.0.evented.get_mut().devfile)
725725
}
726726
}
727727

728-
#[cfg(feature = "use_tokio")]
728+
#[cfg(feature = "async-tokio")]
729729
impl Stream for PinValueStream {
730730
type Item = u8;
731731
type Error = Error;

0 commit comments

Comments
 (0)