Skip to content

Commit

Permalink
Add support for mio 0.8;
Browse files Browse the repository at this point in the history
mio release its 0.8.x version whose APIs are compatible with 0.7.x.

Signed-off-by: Douglas Su <d0u9.su@outlook.com>
  • Loading branch information
d0u9 authored and Drakulix committed Dec 15, 2021
1 parent caeb9d2 commit 1f765d2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
16 changes: 9 additions & 7 deletions src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -257,7 +259,7 @@ impl Evented for Socket {
fn register(
&self,
poll: &Poll,
token: Token06,
token: Token,
interest: Ready,
opts: PollOpt,
) -> std::io::Result<()> {
Expand All @@ -267,7 +269,7 @@ impl Evented for Socket {
fn reregister(
&self,
poll: &Poll,
token: Token06,
token: Token,
interest: Ready,
opts: PollOpt,
) -> std::io::Result<()> {
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 1f765d2

Please sign in to comment.