Linux, rust, watch, incrementally map a directory

  1. I'm using Rust on linux x86_64.

  2. I have a function f: String -> String

  3. I have an input directory "/input" and output directory "/output"

  4. I want to maintain the invariant that for every path (may contain subdirectories) $p, /output/$p contains the contents of f( /input/$p )

  5. The way to do this is we setup a watcher on all of /input which watches for things like: new file, update file, remove file

Question: is there something to handle this for me already ? If not, what 'watcher' crate is recommended to build up this "directory incremental mapping" myself ?

Thanks!

Are you looking for a crate to tell you which files are changed, or for a crate to help you keep track of which paths to run your function on?

I'd be very surprised to see a crate specialized for this.

A search for "file watcher" brings up watchexec.

For watching changes on the filesystem I would recommend either the Linux specific inotify crate, or the higher-level, platform independent notify crate.