| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/, timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/}; |
| 3 | |
| 4 | fn mainrust-analyzer cargo udevrs 0.4.0 main().() -> udevrsrust-analyzer cargo udevrs 0.4.0 crate/::Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> { |
| 5 | env_loggerrust-analyzer cargo env_logger 0.11.6 crate/::initrust-analyzer cargo env_logger 0.11.6 logger/init().(); |
| 6 | let udev = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(udevrsrust-analyzer cargo udevrs 0.4.0 crate/::Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#::newrust-analyzer cargo udevrs 0.4.0 context/impl#[Udev]new().()); |
| 7 | let mut monitor = udevrsrust-analyzer cargo udevrs 0.4.0 crate/::UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#::new_from_netlinkrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]new_from_netlink().(udev, "udev")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 8 | |
| 9 | monitor.enable_receivingrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]enable_receiving().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 10 | |
| 11 | loop { |
| 12 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", monitor.receive_devicerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]receive_device().()); |
| 13 | |
| 14 | threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(1)); |
| 15 | } |
| 16 | } |