Crate calloop_notify
source · [−]Expand description
Watch files using calloop
.
This crate provides a wrapper around the notify
crate to allow
integration with the calloop
event loop. To get started, just create a
NotifySource
and insert it into your event loop.
Example
use std::path::Path;
use calloop::EventLoop;
use calloop_notify::notify::{RecursiveMode, Watcher};
use calloop_notify::NotifySource;
// Create calloop event loop.
let mut event_loop = EventLoop::try_new().unwrap();
let loop_handle = event_loop.handle();
// Watch current directory recursively.
let mut notify_source = NotifySource::new().unwrap();
notify_source.watch(Path::new("."), RecursiveMode::Recursive).unwrap();
// Insert notify source into calloop.
loop_handle
.insert_source(notify_source, |event, _, _: &mut ()| {
println!("Notify Event: {event:?}");
})
.unwrap();
// Dispatch event loop.
loop {
event_loop.dispatch(None, &mut ()).unwrap();
}
Re-exports
pub use notify;
Structs
Calloop event source for watching files.