neco-watchnorm 0.1.1

Host-agnostic file watcher event normalization and batch coalescing
Documentation
  • Coverage
  • 26.83%
    11 out of 41 items documented0 out of 10 items with examples
  • Size
  • Source code size: 25.79 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.33 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 35s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • barineco/neco-editor
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • barineco

neco-watchnorm

日本語

neco-watchnorm normalizes host-specific file watcher events into a deterministic batch API for downstream runtime logic.

Event normalization

The crate accepts host-side watcher events as RawWatchEvent, then converts them into a smaller normalized event stream during drain(). Callers provide a generation number, and the normalizer drops stale events, joins rename halves when possible, and keeps incomplete rename information as PartialRename instead of guessing.

Modify coalescing is conservative. Repeated modifies for the same path collapse, an immediate modify after create is absorbed, and removes discard earlier modifies for the same path in the current batch.

Usage

use neco_watchnorm::{
    NormalizedWatchKind, RawWatchEvent, RawWatchKind, RenameHint, WatchBatchNormalizer,
};

let mut normalizer = WatchBatchNormalizer::new();
normalizer.push(RawWatchEvent {
    kind: RawWatchKind::Rename,
    paths: vec!["/old.txt".into()],
    rename_from: Some("/old.txt".into()),
    rename_to: None,
    rename_hint: Some(RenameHint::From),
    generation: 2,
});
normalizer.push(RawWatchEvent {
    kind: RawWatchKind::Rename,
    paths: vec!["/new.txt".into()],
    rename_from: None,
    rename_to: Some("/new.txt".into()),
    rename_hint: Some(RenameHint::To),
    generation: 2,
});

let result = normalizer.drain(2);
assert_eq!(result.events.len(), 1);
assert!(matches!(
    result.events[0].kind,
    NormalizedWatchKind::Rename { .. }
));

API

Item Description
RawWatchEvent Host-agnostic batch input event with generation metadata
RawWatchKind Raw create / remove / modify / rename discriminator
RenameHint Optional rename-side hint from the host bridge
NormalizedWatchEvent Consumer-facing normalized event with generation
NormalizedWatchKind Create, Remove, Modify, Rename, and PartialRename
WatchBatchNormalizer Stateful batch normalizer with push and drain
FlushResult Normalized output events and stale discard count

License

MIT