pub async fn make_watcher<T>(
platform: &str,
poll_interval: u64,
handler: T,
) -> Result<Watcher<T>, Error>where
T: WatcherHandler,Expand description
Creates and initializes a new Watcher to monitor file changes on a specified platform.
§Parameters
platform: A string representing the target platform for the watcher (e.g.,"pfsense"or"opnsense").poll_interval: The polling interval in milliseconds to check for file changes.handler: A user-defined function or closure that gets executed when a change is detected. This function must implement theWatcherHandlertrait.
§Returns
Ok(Watcher<T>): A successfully initializedWatcherinstance configured for the given platform.Err(Error): Returns an error if initialization fails.
§Errors
- Returns
ErrorKind::ErrorUnsupportedPlatformif the specified platform is not recognized. - Returns
ErrorKind::ErrorInitializingWatcherif the watcher fails to initialize.