pub struct UCXLWatcher { /* private fields */ }Expand description
Represents a watcher rooted at a specific base path.
What: Holds the absolute path that the watcher monitors.
How: The path is stored as a PathBuf. The watcher is created via the
new constructor which accepts any type that can be referenced as a Path.
The underlying notify::RecommendedWatcher is configured with the default
Config and set to watch recursively.
Why: Encapsulating the watcher logic in a dedicated struct makes it easy to instantiate multiple independent watchers and keeps the public API tidy.
Implementations§
Source§impl UCXLWatcher
impl UCXLWatcher
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Self
pub fn new<P: AsRef<Path>>(path: P) -> Self
Creates a new UCXLWatcher for the given path.
What: Accepts any generic AsRef<Path> so callers can pass a &str,
Path, or PathBuf.
How: The provided path is converted to a PathBuf and stored.
Why: Convenience constructor used throughout CHORUS when a watcher is needed for a project directory.
Sourcepub fn watch_loop(&self) -> Result<(), Box<dyn Error>>
pub fn watch_loop(&self) -> Result<(), Box<dyn Error>>
Starts the watch loop, blocking indefinitely while handling events.
What: Sets up a channel, creates a RecommendedWatcher, and begins
watching the base_path recursively. For each incoming event, it
attempts to map the filesystem path to a UCXL address and prints a log.
How: Uses the notify crate’s event API. The heuristic address
format is ucxl://system:watcher@local:filesystem/#/<relative_path>.
It parses this string with UCXLAddress::from_str and logs the result.
Errors from parsing are ignored (they simply aren’t printed).
Why: Provides a simple, observable bridge between raw filesystem changes and the UCXL addressing scheme, allowing other components to react to changes using a uniform identifier.