tokio_devd/lib.rs
1//! # tokio-devd
2//!
3//! A simple Tokio-based library for listening to `devd` device events on FreeBSD
4//!
5//! This has been built to imitate `tokio-udev`'s API, since I wanted to port a
6//! program using said library to FreeBSD, and I wanted to do it as frictionless
7//! as possible. However, due to limitations inherent to reading `devd`'s
8//! events, it is not possible to have such an extensive amount of
9//! functionalities, or at least not with my current knowledge of things.
10//!
11//! This library depends heavily on valpackett's `devd-rs`. Kudos to her.
12//!
13//! **Disclaimer**: This crate was done in less than a day by me, and I'm
14//! honestly not knowledgeable enough about Tokio or advanced Rust topics. If
15//! you find opportunities for improvement, I encourage you to make a pull
16//! request or suggest any changes.
17//!
18//! ## Example
19//!
20//! ```
21//! use futures_util::stream::StreamExt;
22//! use tokio_devd::MonitorBuilder;
23//!
24//! #[tokio::main]
25//! async fn main() -> std::io::Result<()> {
26//! let mut monitor = MonitorBuilder::new().match_subsystem("CDEV")?.listen()?;
27//!
28//! println!("Listening for events...");
29//! while let Some(event_res) = monitor.next().await {
30//! if let Ok(event) = event_res {
31//! println!("{:?}", event);
32//! }
33//! }
34//! Ok(())
35//! }
36//! ```
37
38#![cfg(target_os = "freebsd")]
39
40mod event;
41mod monitor;
42mod socket;
43
44pub use event::{Device, Event, EventType};
45pub use monitor::{MonitorBuilder, MonitorSocket};