Crate fs_change_notifier

Source
Expand description

FS changes’ notifier.

Simple library to watch file changes inside given directory.

Usage example:

use fs_change_notifier::{create_watcher, match_event, RecursiveMode};

let root = PathBuf::from(".");
let (mut wr, rx) = create_watcher(|e| log::error!("{e:?}")).unwrap();
wr.watch(&root, RecursiveMode::Recursive).unwrap();

loop {
    tokio::select! {
        _ = your_job => {},
        _ = match_event(&root, rx, &exclude) => {
            // do your logic on fs update
        },
    }
}

Enums§

RecursiveMode
Indicates whether only the provided directory or its sub-directories as well should be watched

Functions§

create_watcher
Creates a watcher and an associated MPSC channel receiver.
fetch_changed
Matches event and returns changed file.
match_event
Matches event and returns on included ones.