Agentfs Diff
Watching
Live diff watchers in `agentfs-diff` — observe diffs in real time as both filesystems change.
Purpose
Filesystem diff engine with modes, streams, watchers, file metadata comparisons, and change details.
This page follows the real source shape for Agentfs Diff and explains the workflow a developer is likely to use first.
Developer workflow
Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.
Primary types to know
AgentFSWrapper— local/agentfs-diff/src/comparison.rsDiff— local/agentfs-diff/src/diff.rsDiffEngine— local/agentfs-diff/src/engine.rsDiffOptions— local/agentfs-diff/src/engine.rsDiffStream— local/agentfs-diff/src/stream.rsDiffWatcher— local/agentfs-diff/src/watcher.rsDirectoryDiff— local/agentfs-diff/src/diff.rsEntryInfo— local/agentfs-diff/src/comparison.rsFileDiff— local/agentfs-diff/src/diff.rsMetadataDiff— local/agentfs-diff/src/diff.rsSymlinkDiff— local/agentfs-diff/src/diff.rsWatchOptions— local/agentfs-diff/src/watcher.rs
Example shape
use agentfs_diff::{DiffWatcher, FileSystem, WatchOptions};
use std::sync::Arc;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let source: Arc<dyn FileSystem> = Arc::new(my_fs_source());
let target: Arc<dyn FileSystem> = Arc::new(my_fs_target());
// WatchOptions wires the diff scheduler: polling interval, debounce window,
// and the underlying DiffOptions used for each comparison pass.
let options = WatchOptions {
interval: Duration::from_secs(2),
initial_scan: true,
debounce: Duration::from_millis(250),
..WatchOptions::default()
};
let mut watcher = DiffWatcher::new(source, target, options);
let mut rx = watcher.receiver().expect("receiver must be available before start");
watcher.start().await?;
if let Some(diff) = rx.recv().await {
println!("first diff: kind={:?} path={:?}", diff.kind, diff.path());
}
watcher.stop();
Ok(())
}
# fn my_fs_source() -> impl agentfs_diff::FileSystem { unimplemented!() }
# fn my_fs_target() -> impl agentfs_diff::FileSystem { unimplemented!() }