Quadoculars

Concurrent, composable simple file watcher on top of notify-rs.

Features

Installation

Add quadoculars as a dependency in your Cargo.toml:

toml quadoculars = "*"

or

toml quadoculars = { git = https://github.com/Ar37-rs/quadoculars.git }

Quick Example

```rust use quadoculars::{Fstate, Watch}; use std::{ io::Result, path::{Path, PathBuf}, str::FromStr, sync::mpsc::channel, };

fn main() -> Result<()> { let file: PathBuf; match PathBuf::fromstr("filename.extention") { Ok(file) => file = file, _ => file = Path::new("otherfilename.otherextension").topath_buf(), }

let (tx, rx) = channel();

while let Ok(file_exist) = Watch::new().set_timeout(0.6).single_file(&file, tx.clone()) {
    if !file_exist {
        println!("no file to watch");
        break;
    } else {
        println!("watching... {:?}", file)
    }
    for state in &rx {
        match state {
            Fstate::Changed(file) => {
                println!("{:?} changed", file);
                // do something...
            }
            Fstate::NotFound(file) => {
                // do handling...
                break;
            }
        }
    }
}
Ok(())

}

```