Struct hotwatch::Hotwatch [] [src]

pub struct Hotwatch { /* fields omitted */ }

Methods

impl Hotwatch
[src]

Creates a new hotwatch instance.

Errors

This function can fail if the underlying notify instance fails to initialize. This will unfortunately expose you to notify's own error type; hotwatch doesn't perfectly encapsulate this.

Examples

use hotwatch::Hotwatch;

let hotwatch = Hotwatch::new().expect("Hotwatch failed to initialize.");

Watch a path and register a handler to it.

Note that handlers will be run in hotwatch's watch thread, so you'll have to use move if the closure captures anything.

Errors

Watching will fail if the path can't be read, thus returning a hotwatch::Error::Io(std::io::Error).

Examples

use hotwatch::{Hotwatch, Event};

let mut hotwatch = Hotwatch::new().expect("Hotwatch failed to initialize.");
hotwatch.watch("README.md", |e: Event| {
    if let Event::Write(path) = e {
        println!("{:?} changed!", path);
    }
}).expect("Failed to watch file!");