Struct UCXLWatcher

Source
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

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.