From 0ab69a017da1f435a28cf96e8d4911d00b862f97 Mon Sep 17 00:00:00 2001 From: Jonas Meer Date: Wed, 10 Jul 2024 14:58:49 +0200 Subject: [PATCH] Add support for mio 1.0 --- .github/workflows/ci.yml | 1 + Cargo.toml | 3 ++- examples/monitor.rs | 17 ++++++++++++++--- src/lib.rs | 2 ++ src/monitor.rs | 4 +++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8b1a9b..99acbdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -144,6 +144,7 @@ jobs: - --no-default-features --features "mio06" - --no-default-features --features "mio07" - --no-default-features --features "mio08" + - --no-default-features --features "mio10" - --no-default-features --features "hwdb" - '' # default include: diff --git a/Cargo.toml b/Cargo.toml index 082b769..dd7afcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,11 @@ 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 } +mio10 = { package = "mio", version = "1.0", 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 = ["mio08"] # mio feature defaults to the newest mio version +mio = ["mio10"] # mio feature defaults to the newest mio version hwdb = [] diff --git a/examples/monitor.rs b/examples/monitor.rs index ca555ff..9b650de 100644 --- a/examples/monitor.rs +++ b/examples/monitor.rs @@ -5,11 +5,18 @@ extern crate mio06; extern crate mio07; #[cfg(feature = "mio08")] extern crate mio08; +#[cfg(feature = "mio10")] +extern crate mio10; extern crate udev; use std::io; -#[cfg(not(any(feature = "mio06", feature = "mio07", feature = "mio08")))] +#[cfg(not(any( + feature = "mio06", + feature = "mio07", + feature = "mio08", + feature = "mio10" +)))] mod poll { use std::io; use std::ptr; @@ -114,7 +121,7 @@ mod poll { } } -#[cfg(any(feature = "mio07", feature = "mio08"))] +#[cfg(any(feature = "mio07", feature = "mio08", feature = "mio10"))] mod poll { use std::io; @@ -122,12 +129,16 @@ mod poll { use mio07::{Events, Interest, Poll, Token}; #[cfg(feature = "mio08")] use mio08::{Events, Interest, Poll, Token}; + #[cfg(feature = "mio10")] + use mio10::{Events, Interest, Poll, Token}; pub fn poll(mut socket: udev::MonitorSocket) -> io::Result<()> { let version = if cfg!(feature = "mio07") { "mio07" } else if cfg!(feature = "mio08") { "mio08" + } else if cfg!(feature = "mio10") { + "mio10" } else { "mio-unknown" }; @@ -169,7 +180,7 @@ fn print_event(event: udev::Event) { } // Use `mio::poll` as poller by compile with: -// `cargo run --example monitor --features "mio08"` +// `cargo run --example monitor --features "mio10"` fn main() -> io::Result<()> { let socket = udev::MonitorBuilder::new()? // .match_subsystem_devtype("usb", "usb_device")? diff --git a/src/lib.rs b/src/lib.rs index 2c14afb..b92dd99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,8 @@ extern crate mio06; extern crate mio07; #[cfg(feature = "mio08")] extern crate mio08; +#[cfg(feature = "mio10")] +extern crate mio10; pub use device::{Attributes, Device, DeviceType, Properties}; pub use enumerator::{Devices, Enumerator}; diff --git a/src/monitor.rs b/src/monitor.rs index 71adf1a..7dac6c9 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -13,6 +13,8 @@ use mio06::{event::Evented, unix::EventedFd, Poll, PollOpt, Ready, Token}; use mio07::{event::Source, unix::SourceFd, Interest, Registry, Token}; #[cfg(feature = "mio08")] use mio08::{event::Source, unix::SourceFd, Interest, Registry, Token}; +#[cfg(feature = "mio10")] +use mio10::{event::Source, unix::SourceFd, Interest, Registry, Token}; use Udev; use {ffi, util}; @@ -334,7 +336,7 @@ impl Evented for Socket { } } -#[cfg(any(feature = "mio07", feature = "mio08"))] +#[cfg(any(feature = "mio07", feature = "mio08", feature = "mio10"))] impl Source for Socket { fn register( &mut self,