pub struct Watcher<H: WatcherHandler> { /* private fields */ }Expand description
A file watcher that monitors specified files for changes and notifies a handler when updates occur.
Implementations§
Source§impl<H: WatcherHandler> Watcher<H>
impl<H: WatcherHandler> Watcher<H>
Sourcepub async fn new(
platform: Platform,
poll_interval: u64,
handler: H,
) -> Result<Self, Error>
pub async fn new( platform: Platform, poll_interval: u64, handler: H, ) -> Result<Self, Error>
Creates a new Watcher instance that monitors configuration files for changes.
§Parameters
platform: The target platform for which the configuration state should be monitored.poll_interval: Time interval (in milliseconds) to check for file changes.handler: An instance implementingWatcherHandlerfor handling snapshots and errors.
§Returns
Ok(Self): A properly initializedWatcherinstance.Err(Error): If any file metadata cannot be retrieved.
Sourcepub async fn watch(&mut self)
pub async fn watch(&mut self)
Starts monitoring the files and system state for changes.
This function continuously checks the monitored files for modifications
and observes system state transitions. When a file modification or a
relevant state transition (from Draft to Applied) is detected, it
triggers the on_snapshot method of the handler.
§Returns
Ok(())if the monitoring process runs smoothly.Err(Error)if an unrecoverable error occurs.
Sourcepub async fn check_files_for_changes(&mut self) -> bool
pub async fn check_files_for_changes(&mut self) -> bool
Checks the monitored files for modifications.
Sourcepub async fn handle_snapshot(&mut self)
pub async fn handle_snapshot(&mut self)
Captures and processes a snapshot of the monitored files and system state.
Auto Trait Implementations§
impl<H> Freeze for Watcher<H>where
H: Freeze,
impl<H> RefUnwindSafe for Watcher<H>where
H: RefUnwindSafe,
impl<H> Send for Watcher<H>where
H: Send,
impl<H> Sync for Watcher<H>where
H: Sync,
impl<H> Unpin for Watcher<H>where
H: Unpin,
impl<H> UnwindSafe for Watcher<H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more