fn start_stream(file_path: PathBuf) -> Option<(FileWatchMessage, State)> {
        log::info!("Starting file-watcher over {}", file_path.to_str().unwrap());
        let (tx, rx) = channel();
        let (output_tx, output_rx) = tokio::sync::mpsc::channel(BUFFER_SIZE);

        if let Ok(mut watcher) = watcher(tx, Duration::from_secs(2)) {
            if let Err(err) = watcher.watch(file_path.clone(), RecursiveMode::NonRecursive) {
                log::error!("Failure to watch path {}", err);
                return Some((FileWatchMessage::Error, State::Finished));
            }

            let thread = tokio::task::spawn_blocking({
                let plugin_file = file_path;
                move || run_file_watch_loop(&plugin_file, rx, output_tx)
            });
            Some((
                FileWatchMessage::Started,
                State::Watching {
                    thread,
                    watcher,
                    message_rx: output_rx,
                },
            ))
        } else {
            Some((FileWatchMessage::Error, State::Finished))
        }
    }
/// Start the file-watcher thread and update the state.
Start the file-watcher thread and update the state.
Start the file - watcher thread and update the state .
fn start_stream(file_path: PathBuf) -> Option<(FileWatchMessage, State)> {
        log::info!("Starting file-watcher over {}", file_path.to_str().unwrap());
        let (tx, rx) = channel();
        let (output_tx, output_rx) = tokio::sync::mpsc::channel(BUFFER_SIZE);
        if let Ok(mut watcher) = watcher(tx, Duration::from_secs(2)) {
            if let Err(err) = watcher.watch(file_path.clone(), RecursiveMode::NonRecursive) {
                log::error!("Failure to watch path {}", err);
                return Some((FileWatchMessage::Error, State::Finished));
            }
            let thread = tokio::task::spawn_blocking({
                let plugin_file = file_path;
                move || run_file_watch_loop(&plugin_file, rx, output_tx)
            });
            Some((
                FileWatchMessage::Started,
                State::Watching {
                    thread,
                    watcher,
                    message_rx: output_rx,
                },
            ))
        } else {
            Some((FileWatchMessage::Error, State::Finished))
        }
    }
fn start_stream ( file_path : PathBuf ) -> Option < ( FileWatchMessage , State ) > { log :: info ! ( " " file_path to_str ( ) unwrap ( ) ) ; let ( tx , rx ) = channel ( ) ; let ( output_tx , output_rx ) = tokio :: sync :: mpsc :: channel ( BUFFER_SIZE ) ; if let Ok ( mut watcher ) = watcher ( tx , Duration :: from_secs ( 2 ) ) { if let Err ( err ) = watcher . watch ( file_path . clone ( ) , RecursiveMode :: NonRecursive ) { log :: error ! ( " " err ) ; return Some ( ( FileWatchMessage :: Error , State :: Finished ) ) ; } let thread = tokio :: task :: spawn_blocking ( { let plugin_file = file_path ; move | | run_file_watch_loop ( & plugin_file , rx , output_tx ) } ) ; Some ( ( FileWatchMessage :: Started , State :: Watching { thread , watcher , message_rx : output_rx , } , ) ) } else { Some ( ( FileWatchMessage :: Error , State :: Finished ) ) } }
Start the file-watcher thread and update the state.
Start the file - watcher thread and update the state .
file_path
PathBuf
file_path
PathBuf