watchexec/crates/events
Félix Saparelli 8156864bf3
--emit-events-to (#515)
2023-03-18 21:32:24 +13:00
..
examples --emit-events-to (#515) 2023-03-18 21:32:24 +13:00
src --emit-events-to (#515) 2023-03-18 21:32:24 +13:00
tests --emit-events-to (#515) 2023-03-18 21:32:24 +13:00
CHANGELOG.md --emit-events-to (#515) 2023-03-18 21:32:24 +13:00
Cargo.toml --emit-events-to (#515) 2023-03-18 21:32:24 +13:00
README.md --emit-events-to (#515) 2023-03-18 21:32:24 +13:00
release.toml --emit-events-to (#515) 2023-03-18 21:32:24 +13:00

README.md

watchexec-events

Watchexec's event types.

This is particularly useful if you're building a tool that runs under Watchexec, and want to easily read its events (with --emit-events-to=json-file and --emit-events-to=json-stdin).

use std::io::{stdin, Result};
use watchexec_events::Event;

fn main() -> Result<()> {
    for line in stdin().lines() {
        let event: Event = serde_json::from_str(&line?)?;
        dbg!(event);
    }

    Ok(())
}

Features

  • serde: enables serde support.
  • notify: use Notify's file event types (default).

If you disable notify, you'll get a leaner dependency tree that's still able to parse the entire events, but isn't type compatible with Notify. In most deserialisation usecases, this is fine, but it's not the default to avoid surprises.