pub(super) async fn new_stream(
) -> Result<impl Stream<Item = Result<OIRInfo, anyhow::Error>>, anyhow::Error> {
    let path = ethdir_path();
    let path_as_str = path.to_str().ok_or_else(|| {
        format_err!(
            "path requested for watch is non-utf8 and our non-blocking directory apis require utf8 paths: {:?}.",
            path
        )
    })?;
    debug!("device path: {}", path_as_str);
    let dir_proxy = open_directory_in_namespace(path_as_str, OPEN_RIGHT_READABLE)?;
    let watcher = fuchsia_vfs_watcher::Watcher::new(dir_proxy)
        .await
        .with_context(|| format!("could not watch {:?}", path))?;

    Ok(watcher
        .map(|r| r.context("getting next VFS event from"))
        .try_filter_map(|fuchsia_vfs_watcher::WatchMessage { event, filename }| async move {
            info!("received {:?} event for filename: {:?}", event, filename);

            if filename == path::PathBuf::from(THIS_DIRECTORY) {
                debug!("skipping filename = {}", filename.display());
                return Ok(None);
            }

            match event {
                fuchsia_vfs_watcher::WatchEvent::ADD_FILE
                | fuchsia_vfs_watcher::WatchEvent::EXISTING => Ok(device_found(&filename).await?),
                fuchsia_vfs_watcher::WatchEvent::IDLE => Ok(None),
                fuchsia_vfs_watcher::WatchEvent::REMOVE_FILE => Ok(Some(device_removed(&filename))),
                event => {
                    warn!("received unknown event {:?} for filename: {:?}", event, filename);
                    Ok(None)
                }
            }
        })
        .map(move |r| r.with_context(|| format!("watching {:?}", path))))
}
/// Returns a `Stream` that yields `OIRInfo`s in response to events from the
/// device filesystem.
Returns a `Stream` that yields `OIRInfo`s in response to events from the
device filesystem.
Returns a ` Stream ` that yields ` OIRInfo ` s in response to events from the device filesystem .
pub(super) async fn new_stream(
) -> Result<impl Stream<Item = Result<OIRInfo, anyhow::Error>>, anyhow::Error> {
    let path = ethdir_path();
    let path_as_str = path.to_str().ok_or_else(|| {
        format_err!(
            "path requested for watch is non-utf8 and our non-blocking directory apis require utf8 paths: {:?}.",
            path
        )
    })?;
    debug!("device path: {}", path_as_str);
    let dir_proxy = open_directory_in_namespace(path_as_str, OPEN_RIGHT_READABLE)?;
    let watcher = fuchsia_vfs_watcher::Watcher::new(dir_proxy)
        .await
        .with_context(|| format!("could not watch {:?}", path))?;
    Ok(watcher
        .map(|r| r.context("getting next VFS event from"))
        .try_filter_map(|fuchsia_vfs_watcher::WatchMessage { event, filename }| async move {
            info!("received {:?} event for filename: {:?}", event, filename);
            if filename == path::PathBuf::from(THIS_DIRECTORY) {
                debug!("skipping filename = {}", filename.display());
                return Ok(None);
            }
            match event {
                fuchsia_vfs_watcher::WatchEvent::ADD_FILE
                | fuchsia_vfs_watcher::WatchEvent::EXISTING => Ok(device_found(&filename).await?),
                fuchsia_vfs_watcher::WatchEvent::IDLE => Ok(None),
                fuchsia_vfs_watcher::WatchEvent::REMOVE_FILE => Ok(Some(device_removed(&filename))),
                event => {
                    warn!("received unknown event {:?} for filename: {:?}", event, filename);
                    Ok(None)
                }
            }
        })
        .map(move |r| r.with_context(|| format!("watching {:?}", path))))
}
pub ( super ) async fn new_stream ( ) -> Result < impl Stream < Item = Result < OIRInfo , anyhow :: Error > > , anyhow :: Error > { let path = ethdir_path ( ) ; let path_as_str = path . to_str ( ) . ok_or_else ( | | { format_err ! ( " " path ) } ) ? ; debug ! ( " " path_as_str ) ; let dir_proxy = open_directory_in_namespace ( path_as_str , OPEN_RIGHT_READABLE ) ? ; let watcher = fuchsia_vfs_watcher :: Watcher :: new ( dir_proxy ) . await . with_context ( | | format ! ( " " path ) ) ? ; Ok ( watcher . map ( | r | r . context ( " " ) ) . try_filter_map ( | fuchsia_vfs_watcher :: WatchMessage { event , filename } | async move { info ! ( " " event filename ) ; if filename == path :: PathBuf :: from ( THIS_DIRECTORY ) { debug ! ( " " filename display ( ) ) ; return Ok ( None ) ; } match event { fuchsia_vfs_watcher :: WatchEvent :: ADD_FILE | fuchsia_vfs_watcher :: WatchEvent :: EXISTING => Ok ( device_found ( & filename ) . await ? ) , fuchsia_vfs_watcher :: WatchEvent :: IDLE => Ok ( None ) , fuchsia_vfs_watcher :: WatchEvent :: REMOVE_FILE => Ok ( Some ( device_removed ( & filename ) ) ) , event => { warn ! ( " " event filename ) ; Ok ( None ) } } } ) . map ( move | r | r . with_context ( | | format ! ( " " path ) ) ) ) }
Returns a `Stream` that yields `OIRInfo`s in response to events from the
device filesystem.
Returns a ` Stream ` that yields ` OIRInfo ` s in response to events from the device filesystem .