Smithay/udev-rs

build error

gneworld opened this issue · 2 comments

I copy the Cargo.toml and monitor.rs to a test project and rename it to main.rs, then encounter a build error like this, so what am I missing? thanks much

xxxxOpsasder:~/learn/rust_test$ cargo run --features "mio08"
Compiling udev v0.6.3 (/home/mi/learn/rust_test)
error[E0277]: the trait bound MonitorSocket: Source is not satisfied
--> src/main.rs:139:25
|
139 | poll.registry().register(
| ^^^^^^^^ the trait Source is not implemented for MonitorSocket
|
note: required by a bound in Registry::register
--> /home/mi/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.3/src/poll.rs:497:12
|
497 | S: event::Source + ?Sized,
| ^^^^^^^^^^^^^ required by this bound in Registry::register

For more information about this error, try rustc --explain E0277.
error: could not compile udev due to previous error

You also need to compile udev-rs with the correct feature-set, you cannot just copy the Cargo.toml for that.
You would need to create a new Cargo.toml and depend on udev-rs with the poll-implementation you want to use, e.g.:

[dependencies]
udev = { version = "0.6.3", features = ["mio08"] }

For me the example inside the repository compiles fine with cargo run --features "mio08" --example monitor

I have built passed with your advice, thank you very much~ ^_^