From 9b4efe1fd84c442803a3b9f18ef897531474ef7c Mon Sep 17 00:00:00 2001 From: Guanhao Yin Date: Tue, 10 Sep 2019 17:00:29 +0800 Subject: [PATCH 01/12] feat: update to tokio 0.2 (alpha) and futures 0.3 (preview) `EventStream` is now a futures 0.3 stream (backed by tokio 0.2) and can be used with async/await. The stream example is updated accordingly. The crate is updated to the 2018 edition, so that related tests and examples can be written in async/await. The CI config is modified to: * Run on nightly * Run with `--no-default-features` as well --- Cargo.toml | 22 +++++++++------- examples/stream.rs | 17 +++++------- examples/watch.rs | 3 --- rust-toolchain | 1 + src/events.rs | 7 ++--- src/inotify.rs | 16 ++++++------ src/lib.rs | 17 +++--------- src/stream.rs | 65 +++++++++++++++++++++------------------------- src/watches.rs | 2 +- tests/main.rs | 15 +++++------ 10 files changed, 70 insertions(+), 95 deletions(-) create mode 100644 rust-toolchain diff --git a/Cargo.toml b/Cargo.toml index 757b7c3..69a4fc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ authors = [ "Cristian Kubis ", "Frank Denis " ] +edition = "2018" description = "Idiomatic wrapper for inotify" documentation = "https://docs.rs/inotify" @@ -26,21 +27,22 @@ travis-ci = { repository = "inotify-rs/inotify" } [features] default = ["stream"] -stream = ["futures", "mio", "tokio", "tokio-io", "tokio-reactor"] +stream = ["futures-core-preview", "mio", "tokio-io", "tokio-net"] [dependencies] -bitflags = "1" -futures = { version = "0.1", optional = true } -inotify-sys = "0.1.3" -libc = "0.2" -mio = { version = "0.6", optional = true } -tokio = { version = "0.1", optional = true } -tokio-io = { version = "0.1", optional = true } -tokio-reactor = { version = "0.1", optional = true } +bitflags = "1" +futures-core-preview = { version = "=0.3.0-alpha.18", optional = true } +inotify-sys = "0.1.3" +libc = "0.2" +mio = { version = "0.6", optional = true } +tokio-io = { version = "=0.2.0-alpha.4", optional = true } +tokio-net = { version = "=0.2.0-alpha.4", optional = true, default-features = false } [dev-dependencies] -tempdir = "0.3" +tempdir = "0.3" +futures-util-preview = "=0.3.0-alpha.18" +tokio = "=0.2.0-alpha.4" [[example]] name = "stream" diff --git a/examples/stream.rs b/examples/stream.rs index 7c722e9..48ba2c5 100644 --- a/examples/stream.rs +++ b/examples/stream.rs @@ -1,8 +1,3 @@ -extern crate futures; -extern crate inotify; -extern crate tempdir; - - use std::{ fs::File, io, @@ -10,15 +5,15 @@ use std::{ time::Duration, }; -use futures::Stream; +use futures_util::StreamExt; use inotify::{ Inotify, WatchMask, }; use tempdir::TempDir; - -fn main() -> Result<(), io::Error> { +#[tokio::main] +async fn main() -> Result<(), io::Error> { let mut inotify = Inotify::init() .expect("Failed to initialize inotify"); @@ -34,10 +29,10 @@ fn main() -> Result<(), io::Error> { }); let mut buffer = [0; 32]; - let stream = inotify.event_stream(&mut buffer); + let mut stream = inotify.event_stream(&mut buffer); - for event in stream.wait() { - print!("event: {:?}\n", event); + while let Some(event_or_error) = stream.next().await { + println!("event: {:?}", event_or_error?); } Ok(()) diff --git a/examples/watch.rs b/examples/watch.rs index 3aa7a10..c86ff17 100644 --- a/examples/watch.rs +++ b/examples/watch.rs @@ -1,6 +1,3 @@ -extern crate inotify; - - use std::env; use inotify::{ diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..e608779 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly-2019-09-13 diff --git a/src/events.rs b/src/events.rs index 39d50b8..dda214b 100644 --- a/src/events.rs +++ b/src/events.rs @@ -10,8 +10,8 @@ use std::{ use inotify_sys as ffi; -use fd_guard::FdGuard; -use watches::WatchDescriptor; +use crate::fd_guard::FdGuard; +use crate::watches::WatchDescriptor; /// Iterator over inotify events @@ -111,7 +111,7 @@ impl<'a> Event<&'a OsStr> { let mask = EventMask::from_bits(event.mask) .expect("Failed to convert event mask. This indicates a bug."); - let wd = ::WatchDescriptor { + let wd = crate::WatchDescriptor { id: event.wd, fd, }; @@ -195,6 +195,7 @@ impl<'a> Event<&'a OsStr> { (bytes_consumed, event) } + #[cfg(feature = "stream")] pub(crate) fn into_owned(&self) -> EventOwned { Event { wd: self.wd.clone(), diff --git a/src/inotify.rs b/src/inotify.rs index 6d1eff9..7d576f7 100644 --- a/src/inotify.rs +++ b/src/inotify.rs @@ -23,19 +23,19 @@ use libc::{ fcntl, }; -use events::Events; -use fd_guard::FdGuard; -use util::read_into_buffer; -use watches::{ +use crate::events::Events; +use crate::fd_guard::FdGuard; +use crate::util::read_into_buffer; +use crate::watches::{ WatchDescriptor, WatchMask, }; #[cfg(feature = "stream")] -use tokio_reactor::Handle; +use tokio_net::driver::Handle; #[cfg(feature = "stream")] -use stream::EventStream; +use crate::stream::EventStream; /// Idiomatic Rust wrapper around Linux's inotify API @@ -405,7 +405,7 @@ impl Inotify { pub fn event_stream(&mut self, buffer: T) -> EventStream where - T: AsMut<[u8]> + AsRef<[u8]>, + T: AsMut<[u8]> + AsRef<[u8]> + Unpin, { EventStream::new(self.fd.clone(), buffer) } @@ -422,7 +422,7 @@ impl Inotify { pub fn event_stream_with_handle(&mut self, handle: &Handle, buffer: T) -> io::Result> where - T: AsMut<[u8]> + AsRef<[u8]>, + T: AsMut<[u8]> + AsRef<[u8]> + Unpin, { EventStream::new_with_handle(self.fd.clone(), handle, buffer) } diff --git a/src/lib.rs b/src/lib.rs index 23b993f..3da19aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,17 +73,6 @@ #[macro_use] extern crate bitflags; -extern crate libc; -extern crate inotify_sys; - -#[cfg(feature = "stream")] -#[macro_use] -extern crate futures; - -#[cfg(feature = "stream")] -extern crate tokio_reactor; - - mod events; mod fd_guard; mod inotify; @@ -94,14 +83,14 @@ mod watches; mod stream; -pub use events::{ +pub use crate::events::{ Event, EventMask, EventOwned, Events, }; -pub use inotify::Inotify; -pub use watches::{ +pub use crate::inotify::Inotify; +pub use crate::watches::{ WatchDescriptor, WatchMask, }; diff --git a/src/stream.rs b/src/stream.rs index f0cdc36..b06ffee 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,36 +1,28 @@ -extern crate mio; -extern crate tokio_io; - - use std::{ io, ops::Deref, + pin::Pin, sync::Arc, + task::{Poll, Context}, }; -use self::{ - mio::{ - event::Evented, - unix::EventedFd, - }, - tokio_io::AsyncRead, +use mio::{ + event::Evented, + unix::EventedFd, }; -use futures::{ - Async, - Poll, - Stream, -}; -use tokio_reactor::{ - Handle, - PollEvented, +use tokio_io::AsyncRead; +use futures_core::{Stream, ready}; +use tokio_net::{ + util::PollEvented, + driver::Handle, }; -use events::{ +use crate::events::{ Event, EventOwned, }; -use fd_guard::FdGuard; -use util::read_into_buffer; +use crate::fd_guard::FdGuard; +use crate::util::read_into_buffer; /// Stream of inotify events @@ -47,7 +39,7 @@ pub struct EventStream { impl EventStream where - T: AsMut<[u8]> + AsRef<[u8]>, + T: AsMut<[u8]> + AsRef<[u8]> + Unpin, { /// Returns a new `EventStream` associated with the default reactor. pub(crate) fn new(fd: Arc, buffer: T) -> Self { @@ -78,36 +70,37 @@ where impl Stream for EventStream where - T: AsMut<[u8]> + AsRef<[u8]>, + T: AsMut<[u8]> + AsRef<[u8]> + Unpin, { - type Item = EventOwned; - type Error = io::Error; + type Item = io::Result; - fn poll(&mut self) -> Poll, Self::Error> + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - if self.unused_bytes == 0 { + let self_ = self.get_mut(); + + if self_.unused_bytes == 0 { // Nothing usable in buffer. Need to reset and fill buffer. - self.buffer_pos = 0; - self.unused_bytes = try_ready!(self.fd.poll_read(&mut self.buffer.as_mut())); + self_.buffer_pos = 0; + self_.unused_bytes = ready!(Pin::new(&mut self_.fd).poll_read(cx, self_.buffer.as_mut()))?; } - if self.unused_bytes == 0 { + if self_.unused_bytes == 0 { // The previous read returned `0` signalling end-of-file. Let's // signal end-of-stream to the caller. - return Ok(Async::Ready(None)); + return Poll::Ready(None); } // We have bytes in the buffer. inotify doesn't put partial events in // there, and we only take complete events out. That means we have at // least one event in there and can call `from_buffer` to take it out. let (bytes_consumed, event) = Event::from_buffer( - Arc::downgrade(self.fd.get_ref()), - &self.buffer.as_ref()[self.buffer_pos..], + Arc::downgrade(self_.fd.get_ref()), + &self_.buffer.as_ref()[self_.buffer_pos..], ); - self.buffer_pos += bytes_consumed; - self.unused_bytes -= bytes_consumed; + self_.buffer_pos += bytes_consumed; + self_.unused_bytes -= bytes_consumed; - Ok(Async::Ready(Some(event.into_owned()))) + Poll::Ready(Some(Ok(event.into_owned()))) } } diff --git a/src/watches.rs b/src/watches.rs index c3728d9..45a9f1e 100644 --- a/src/watches.rs +++ b/src/watches.rs @@ -9,7 +9,7 @@ use std::{ use inotify_sys as ffi; -use fd_guard::FdGuard; +use crate::fd_guard::FdGuard; bitflags! { diff --git a/tests/main.rs b/tests/main.rs index a8652fb..777a706 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -4,10 +4,6 @@ // This test suite is incomplete and doesn't cover all available functionality. // Contributions to improve test coverage would be highly appreciated! -extern crate futures; -extern crate inotify; -extern crate tempdir; - use inotify::{ Inotify, WatchMask, @@ -47,8 +43,9 @@ fn it_should_watch_a_file() { assert!(num_events > 0); } -#[test] -fn it_should_watch_a_file_async() { +#[cfg(feature = "stream")] +#[tokio::test] +async fn it_should_watch_a_file_async() { let mut testdir = TestDir::new(); let (path, mut file) = testdir.new_file(); @@ -59,12 +56,12 @@ fn it_should_watch_a_file_async() { let mut buffer = [0; 1024]; - use futures::Stream; + use futures_util::StreamExt; let events = inotify .event_stream(&mut buffer[..]) .take(1) - .wait() - .collect::>(); + .collect::>() + .await; let mut num_events = 0; for event in events { From d9460568dca5bf8d5cefcdd1c5213059406a65c9 Mon Sep 17 00:00:00 2001 From: Guanhao Yin Date: Thu, 19 Sep 2019 00:47:27 +0800 Subject: [PATCH 02/12] Don't require that the buffer type is Unpin --- src/inotify.rs | 4 ++-- src/stream.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/inotify.rs b/src/inotify.rs index 7d576f7..944e2a4 100644 --- a/src/inotify.rs +++ b/src/inotify.rs @@ -405,7 +405,7 @@ impl Inotify { pub fn event_stream(&mut self, buffer: T) -> EventStream where - T: AsMut<[u8]> + AsRef<[u8]> + Unpin, + T: AsMut<[u8]> + AsRef<[u8]>, { EventStream::new(self.fd.clone(), buffer) } @@ -422,7 +422,7 @@ impl Inotify { pub fn event_stream_with_handle(&mut self, handle: &Handle, buffer: T) -> io::Result> where - T: AsMut<[u8]> + AsRef<[u8]> + Unpin, + T: AsMut<[u8]> + AsRef<[u8]>, { EventStream::new_with_handle(self.fd.clone(), handle, buffer) } diff --git a/src/stream.rs b/src/stream.rs index b06ffee..1f18013 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -39,7 +39,7 @@ pub struct EventStream { impl EventStream where - T: AsMut<[u8]> + AsRef<[u8]> + Unpin, + T: AsMut<[u8]> + AsRef<[u8]>, { /// Returns a new `EventStream` associated with the default reactor. pub(crate) fn new(fd: Arc, buffer: T) -> Self { @@ -70,13 +70,14 @@ where impl Stream for EventStream where - T: AsMut<[u8]> + AsRef<[u8]> + Unpin, + T: AsMut<[u8]> + AsRef<[u8]>, { type Item = io::Result; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - let self_ = self.get_mut(); + // Safety: safe because we never move out of `self_`. + let self_ = unsafe { self.get_unchecked_mut() }; if self_.unused_bytes == 0 { // Nothing usable in buffer. Need to reset and fill buffer. From 9c83429a27a6b66103ca27cf96ef6af459391f28 Mon Sep 17 00:00:00 2001 From: Guanhao Yin Date: Sat, 21 Sep 2019 18:14:14 +0800 Subject: [PATCH 03/12] Update tokio to 0.2.0-alpha.5 --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 69a4fc6..c538bd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,13 +36,13 @@ futures-core-preview = { version = "=0.3.0-alpha.18", optional = true } inotify-sys = "0.1.3" libc = "0.2" mio = { version = "0.6", optional = true } -tokio-io = { version = "=0.2.0-alpha.4", optional = true } -tokio-net = { version = "=0.2.0-alpha.4", optional = true, default-features = false } +tokio-io = { version = "=0.2.0-alpha.5", optional = true } +tokio-net = { version = "=0.2.0-alpha.5", optional = true, default-features = false } [dev-dependencies] tempdir = "0.3" futures-util-preview = "=0.3.0-alpha.18" -tokio = "=0.2.0-alpha.4" +tokio = "=0.2.0-alpha.5" [[example]] name = "stream" From 736a3cf8e9207b2752f62252e59dcf9e899ddb5e Mon Sep 17 00:00:00 2001 From: Guanhao Yin Date: Wed, 2 Oct 2019 15:26:09 +0800 Subject: [PATCH 04/12] Update tokio and futures tokio 0.2.0-alpha.6 futures 0.3.0-alpha.19 --- Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c538bd8..326a96d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,17 +32,17 @@ stream = ["futures-core-preview", "mio", "tokio-io", "tokio-net"] [dependencies] bitflags = "1" -futures-core-preview = { version = "=0.3.0-alpha.18", optional = true } +futures-core-preview = { version = "=0.3.0-alpha.19", optional = true } inotify-sys = "0.1.3" libc = "0.2" mio = { version = "0.6", optional = true } -tokio-io = { version = "=0.2.0-alpha.5", optional = true } -tokio-net = { version = "=0.2.0-alpha.5", optional = true, default-features = false } +tokio-io = { version = "=0.2.0-alpha.6", optional = true } +tokio-net = { version = "=0.2.0-alpha.6", optional = true, default-features = false } [dev-dependencies] tempdir = "0.3" -futures-util-preview = "=0.3.0-alpha.18" -tokio = "=0.2.0-alpha.5" +futures-util-preview = "=0.3.0-alpha.19" +tokio = "=0.2.0-alpha.6" [[example]] name = "stream" From e99d8a4c82ae84e61b15d37048f846b36bd79d08 Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Mon, 21 Oct 2019 11:50:54 +0800 Subject: [PATCH 05/12] Use the beta toolchain --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index e608779..65b2df8 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2019-09-13 +beta From 7b15937330532c05261c6f99cf361005e93dc08e Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Fri, 1 Nov 2019 08:17:19 +0100 Subject: [PATCH 06/12] Update to use latest tokio --- Cargo.toml | 15 +++++++++++---- examples/stream.rs | 2 +- src/inotify.rs | 21 +-------------------- src/stream.rs | 27 ++++----------------------- tests/main.rs | 1 + 5 files changed, 18 insertions(+), 48 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 326a96d..2c726e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ travis-ci = { repository = "inotify-rs/inotify" } [features] default = ["stream"] -stream = ["futures-core-preview", "mio", "tokio-io", "tokio-net"] +stream = ["futures-core-preview", "mio", "tokio"] [dependencies] @@ -36,13 +36,20 @@ futures-core-preview = { version = "=0.3.0-alpha.19", optional = true } inotify-sys = "0.1.3" libc = "0.2" mio = { version = "0.6", optional = true } -tokio-io = { version = "=0.2.0-alpha.6", optional = true } -tokio-net = { version = "=0.2.0-alpha.6", optional = true, default-features = false } + +[dependencies.tokio] +git = "https://github.com/tokio-rs/tokio.git" +default-features = false +optional = true +features = [ + "io", + "net-driver", +] [dev-dependencies] tempdir = "0.3" futures-util-preview = "=0.3.0-alpha.19" -tokio = "=0.2.0-alpha.6" +tokio = { git = "https://github.com/tokio-rs/tokio.git", default-features = true } [[example]] name = "stream" diff --git a/examples/stream.rs b/examples/stream.rs index 48ba2c5..9a64284 100644 --- a/examples/stream.rs +++ b/examples/stream.rs @@ -29,7 +29,7 @@ async fn main() -> Result<(), io::Error> { }); let mut buffer = [0; 32]; - let mut stream = inotify.event_stream(&mut buffer); + let mut stream = inotify.event_stream(&mut buffer)?; while let Some(event_or_error) = stream.next().await { println!("event: {:?}", event_or_error?); diff --git a/src/inotify.rs b/src/inotify.rs index 944e2a4..87a7e9f 100644 --- a/src/inotify.rs +++ b/src/inotify.rs @@ -31,8 +31,6 @@ use crate::watches::{ WatchMask, }; -#[cfg(feature = "stream")] -use tokio_net::driver::Handle; #[cfg(feature = "stream")] use crate::stream::EventStream; @@ -403,28 +401,11 @@ impl Inotify { /// [`Inotify::event_stream_with_handle`]: struct.Inotify.html#method.event_stream_with_handle #[cfg(feature = "stream")] pub fn event_stream(&mut self, buffer: T) - -> EventStream - where - T: AsMut<[u8]> + AsRef<[u8]>, - { - EventStream::new(self.fd.clone(), buffer) - } - - /// Create a stream which collects events, associated with the given - /// reactor. - /// - /// This functions identically to [`Inotify::event_stream`], except that - /// the returned stream will be associated with the given reactor, rather - /// than the default. - /// - /// [`Inotify::event_stream`]: struct.Inotify.html#method.event_stream - #[cfg(feature = "stream")] - pub fn event_stream_with_handle(&mut self, handle: &Handle, buffer: T) -> io::Result> where T: AsMut<[u8]> + AsRef<[u8]>, { - EventStream::new_with_handle(self.fd.clone(), handle, buffer) + EventStream::new(self.fd.clone(), buffer) } /// Closes the inotify instance diff --git a/src/stream.rs b/src/stream.rs index 1f18013..e9e56c3 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -10,12 +10,9 @@ use mio::{ event::Evented, unix::EventedFd, }; -use tokio_io::AsyncRead; +use tokio::io::AsyncRead; use futures_core::{Stream, ready}; -use tokio_net::{ - util::PollEvented, - driver::Handle, -}; +use tokio::net::util::PollEvented; use crate::events::{ Event, @@ -42,25 +39,9 @@ where T: AsMut<[u8]> + AsRef<[u8]>, { /// Returns a new `EventStream` associated with the default reactor. - pub(crate) fn new(fd: Arc, buffer: T) -> Self { - EventStream { - fd: PollEvented::new(EventedFdGuard(fd)), - buffer: buffer, - buffer_pos: 0, - unused_bytes: 0, - } - } - - /// Returns a new `EventStream` associated with the specified reactor. - pub(crate) fn new_with_handle( - fd : Arc, - handle: &Handle, - buffer: T, - ) - -> io::Result - { + pub(crate) fn new(fd: Arc, buffer: T) -> io::Result { Ok(EventStream { - fd: PollEvented::new_with_handle(EventedFdGuard(fd), handle)?, + fd: PollEvented::new(EventedFdGuard(fd))?, buffer: buffer, buffer_pos: 0, unused_bytes: 0, diff --git a/tests/main.rs b/tests/main.rs index 777a706..da10762 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -59,6 +59,7 @@ async fn it_should_watch_a_file_async() { use futures_util::StreamExt; let events = inotify .event_stream(&mut buffer[..]) + .unwrap() .take(1) .collect::>() .await; From de6380526028c2a02be040f5f2d94b960c091b7b Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Fri, 8 Nov 2019 06:24:28 +0100 Subject: [PATCH 07/12] Use futures 0.3 --- Cargo.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2c726e2..2d41152 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,15 +27,15 @@ travis-ci = { repository = "inotify-rs/inotify" } [features] default = ["stream"] -stream = ["futures-core-preview", "mio", "tokio"] +stream = ["futures-core", "mio", "tokio"] [dependencies] -bitflags = "1" -futures-core-preview = { version = "=0.3.0-alpha.19", optional = true } -inotify-sys = "0.1.3" -libc = "0.2" -mio = { version = "0.6", optional = true } +bitflags = "1" +futures-core = { version = "0.3.1", optional = true } +inotify-sys = "0.1.3" +libc = "0.2" +mio = { version = "0.6", optional = true } [dependencies.tokio] git = "https://github.com/tokio-rs/tokio.git" @@ -47,9 +47,9 @@ features = [ ] [dev-dependencies] -tempdir = "0.3" -futures-util-preview = "=0.3.0-alpha.19" -tokio = { git = "https://github.com/tokio-rs/tokio.git", default-features = true } +tempdir = "0.3" +futures-util = "0.3.1" +tokio = { git = "https://github.com/tokio-rs/tokio.git", default-features = true } [[example]] name = "stream" From 01caa4c5c2af6048ed4372c32196045226f8cce6 Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Wed, 27 Nov 2019 07:42:02 +0100 Subject: [PATCH 08/12] Update to tokio v0.2.1 --- Cargo.toml | 12 ++---------- src/stream.rs | 3 +-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2d41152..09860d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,20 +36,12 @@ futures-core = { version = "0.3.1", optional = true } inotify-sys = "0.1.3" libc = "0.2" mio = { version = "0.6", optional = true } - -[dependencies.tokio] -git = "https://github.com/tokio-rs/tokio.git" -default-features = false -optional = true -features = [ - "io", - "net-driver", -] +tokio = { version = "0.2.1", optional = true, features = ["io-driver"] } [dev-dependencies] tempdir = "0.3" futures-util = "0.3.1" -tokio = { git = "https://github.com/tokio-rs/tokio.git", default-features = true } +tokio = { version = "0.2.1", features = ["macros", "rt-core"] } [[example]] name = "stream" diff --git a/src/stream.rs b/src/stream.rs index e9e56c3..fe0211f 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -10,9 +10,8 @@ use mio::{ event::Evented, unix::EventedFd, }; -use tokio::io::AsyncRead; +use tokio::io::{AsyncRead, PollEvented}; use futures_core::{Stream, ready}; -use tokio::net::util::PollEvented; use crate::events::{ Event, From ba74ec49f9981317242315ad5d979ab56e535fbf Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Wed, 27 Nov 2019 07:45:05 +0100 Subject: [PATCH 09/12] Support stable rust again --- rust-toolchain | 1 - 1 file changed, 1 deletion(-) delete mode 100644 rust-toolchain diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 65b2df8..0000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -beta From 96f63204099a02e3ea7aabce5385c9e5685d1345 Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Wed, 27 Nov 2019 07:52:43 +0100 Subject: [PATCH 10/12] Remove reference to event_stream_with_handle in doc --- src/inotify.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/inotify.rs b/src/inotify.rs index 87a7e9f..0dc9659 100644 --- a/src/inotify.rs +++ b/src/inotify.rs @@ -393,12 +393,6 @@ impl Inotify { /// infinite source of events. /// /// An internal buffer which can hold the largest possible event is used. - /// - /// The event stream will be associated with the default reactor. See - /// [`Inotify::event_stream_with_handle`], if you need more control over the - /// reactor used. - /// - /// [`Inotify::event_stream_with_handle`]: struct.Inotify.html#method.event_stream_with_handle #[cfg(feature = "stream")] pub fn event_stream(&mut self, buffer: T) -> io::Result> From 75c4bd103ef8eb7617d4482c0eb9fcc740e2e1c2 Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Thu, 28 Nov 2019 21:28:58 +0100 Subject: [PATCH 11/12] Build and test with --no-default-features in CI --- .github/workflows/rust.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 236cbf8..92a298a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,3 +13,7 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + - name: Build (no default features) + run: cargo build --verbose --no-default-features + - name: Run tests (no default features) + run: cargo test --verbose --no-default-features From 111c2dfd4e473e50bfc1763f3ad8527b4e2a6359 Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Thu, 28 Nov 2019 21:35:52 +0100 Subject: [PATCH 12/12] Use rust 1.39 in CI --- .github/workflows/rust.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 92a298a..f39ca2a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,6 +9,13 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Install rust (1.39) + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.39.0 + override: true + - name: Check rust and cargo version + run: rustc -V && cargo -V - name: Build run: cargo build --verbose - name: Run tests