little-dude / netlink

netlink libraries for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mio integration compile error: the trait bound `netlink_sys::Socket: Source` is not satisfied

hugo-cuenca opened this issue · comments

Compile error

error[E0277]: the trait bound `netlink_sys::Socket: Source` is not satisfied
   --> src/udev.rs:68:17
    |
67  |             .register(
    |              -------- required by a bound introduced by this call
68  |                 &mut socket,
    |                 ^^^^^^^^^^^ the trait `Source` is not implemented for `netlink_sys::Socket`
    |
note: required by a bound in `Registry::register`
   --> /data/user/1000/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/poll.rs:499:12
    |
499 |         S: event::Source + ?Sized,
    |            ^^^^^^^^^^^^^ required by this bound in `Registry::register`

For more information about this error, try `rustc --explain E0277`.

Cargo.toml:

[dependencies]
# [...]
kobject-uevent = "0.1.0"
mio = { version = "0.8.0", features = ["os-ext", "os-poll"] }
netlink-sys = { version = "0.8.2", features = ["mio_socket"] }
# [...]

Test:

    /// udev thread `uevent` netlink socket.
    const UDEV_THREAD_UEVENT_NL_TOKEN: Token = Token(21);
    
    pub fn main() {
        let mut poll = Poll::new().unwrap();
        let mut events = Events::with_capacity(2);

        // uevent socket
        let mut socket = Socket::new(NETLINK_KOBJECT_UEVENT).unwrap();
        let sa = SocketAddr::new(getpid(), 1);
        let mut buf = vec![0; 1024 * 8];
        socket.bind(&sa).unwrap();
        poll.registry().register(
            &mut socket,
            UDEV_THREAD_UEVENT_NL_TOKEN,
            Interest::READABLE
        );

        todo!()
    }

Am I missing something?

Figured it out: I'm using mio 0.8 while netlink-sys uses mio 0.7. Is there a specific reason you wish to stick with 0.7?

In the meantime I'm making a pull request to bump the mio version.

Is there a specific reason you wish to stick with 0.7?

No, I'm just not looking actively for new releases.

Thanks for the MR to fix this :)