Expand description
§tokio-devd
A simple Tokio-based library for listening to devd
device events on FreeBSD
This has been built to imitate tokio-udev
’s API, since I wanted to port a
program using said library to FreeBSD, and I wanted to do it as frictionless
as possible. However, due to limitations inherent to reading devd
’s
events, it is not possible to have such an extensive amount of
functionalities, or at least not with my current knowledge of things.
This library depends heavily on valpackett’s devd-rs
. Kudos to her.
Disclaimer: This crate was done in less than a day by me, and I’m honestly not knowledgeable enough about Tokio or advanced Rust topics. If you find opportunities for improvement, I encourage you to make a pull request or suggest any changes.
§Example
use futures_util::stream::StreamExt;
use tokio_devd::MonitorBuilder;
#[tokio::main]
async fn main() -> std::io::Result<()> {
let mut monitor = MonitorBuilder::new().match_subsystem("CDEV")?.listen()?;
println!("Listening for events...");
while let Some(event_res) = monitor.next().await {
if let Ok(event) = event_res {
println!("{:?}", event);
}
}
Ok(())
}
Structs§
- Device
- Represents a device, containing its properties.
- Event
- Represents a
devd
event. - Monitor
Builder - Builds a
MonitorSocket
that can match a (optional) specified subsystem. - Monitor
Socket - An async monitor of
devd
events.