From 1f765d2178a1018f25d9fe16a9e3a9c3e5052ba1 Mon Sep 17 00:00:00 2001 From: Douglas Su Date: Mon, 13 Dec 2021 22:31:12 +0800 Subject: [PATCH] Add support for mio 0.8; mio release its 0.8.x version whose APIs are compatible with 0.7.x. Signed-off-by: Douglas Su --- .github/workflows/ci.yml | 1 + Cargo.toml | 3 ++- src/lib.rs | 2 ++ src/monitor.rs | 16 +++++++++------- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b7b969..c8b1a9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -143,6 +143,7 @@ jobs: - --no-default-features - --no-default-features --features "mio06" - --no-default-features --features "mio07" + - --no-default-features --features "mio08" - --no-default-features --features "hwdb" - '' # default include: diff --git a/Cargo.toml b/Cargo.toml index 347627b..24d004d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,10 +15,11 @@ libudev-sys = "0.1.4" libc = "0.2" mio06 = { package = "mio", version = "^0.6.21", optional = true } mio07 = { package = "mio", version = "0.7", features = ["os-ext"], optional = true } +mio08 = { package = "mio", version = "0.8", features = ["os-ext"], optional = true } [build-dependencies] pkg-config = "0.3.3" #force a newer version for libudev-sys to fix minimal versions [features] -mio = ["mio07"] # mio feature defaults to the newest mio version +mio = ["mio08"] # mio feature defaults to the newest mio version hwdb = [] diff --git a/src/lib.rs b/src/lib.rs index 250e3f3..86de99a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,8 @@ pub extern crate libudev_sys as ffi; extern crate mio06; #[cfg(feature = "mio07")] extern crate mio07; +#[cfg(feature = "mio08")] +extern crate mio08; pub use device::{Attributes, Device, Properties}; pub use enumerator::{Devices, Enumerator}; diff --git a/src/monitor.rs b/src/monitor.rs index f7eeca7..6b04770 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -7,9 +7,11 @@ use std::ops::Deref; use std::os::unix::io::{AsRawFd, RawFd}; #[cfg(feature = "mio06")] -use mio06::{event::Evented, unix::EventedFd, Poll, PollOpt, Ready, Token as Token06}; +use mio06::{event::Evented, unix::EventedFd, Poll, PollOpt, Ready, Token}; #[cfg(feature = "mio07")] -use mio07::{event::Source, unix::SourceFd, Interest, Registry, Token as Token07}; +use mio07::{event::Source, unix::SourceFd, Interest, Registry, Token}; +#[cfg(feature = "mio08")] +use mio08::{event::Source, unix::SourceFd, Interest, Registry, Token}; use Udev; use {ffi, util}; @@ -257,7 +259,7 @@ impl Evented for Socket { fn register( &self, poll: &Poll, - token: Token06, + token: Token, interest: Ready, opts: PollOpt, ) -> std::io::Result<()> { @@ -267,7 +269,7 @@ impl Evented for Socket { fn reregister( &self, poll: &Poll, - token: Token06, + token: Token, interest: Ready, opts: PollOpt, ) -> std::io::Result<()> { @@ -279,12 +281,12 @@ impl Evented for Socket { } } -#[cfg(feature = "mio07")] +#[cfg(any(feature = "mio07", feature = "mio08"))] impl Source for Socket { fn register( &mut self, registry: &Registry, - token: Token07, + token: Token, interest: Interest, ) -> std::io::Result<()> { SourceFd(&self.as_raw_fd()).register(registry, token, interest) @@ -293,7 +295,7 @@ impl Source for Socket { fn reregister( &mut self, registry: &Registry, - token: Token07, + token: Token, interest: Interest, ) -> std::io::Result<()> { SourceFd(&self.as_raw_fd()).reregister(registry, token, interest)