async fn all_block_devices(dev_root_dir: &DirectoryProxy) -> Result<Vec<DevBlockDevice>, Error> {
    let (block_dir_client, block_dir_server) =
        fidl::endpoints::create_proxy::<DirectoryMarker>().context("create channel pair")?;

    dev_root_dir
        .open(
            OPEN_FLAG_DIRECTORY | OPEN_RW, // flags
            MODE_TYPE_DIRECTORY,           // mode
            "class/block",                 // path
            ServerEnd::new(block_dir_server.into_channel()),
        )
        .context("open() error")?;

    let dirents = files_async::readdir(&block_dir_client)
        .await
        .context("list children of block device dir")?;

    let mut block_devs = Vec::new();
    for child in dirents {
        let (block_client, block_server) =
            fidl::endpoints::create_proxy::<NodeMarker>().context("create Node channel pair")?;
        let open_result = block_dir_client
            .open(
                OPEN_RW,
                MODE_TYPE_SERVICE,
                &child.name,
                ServerEnd::new(block_server.into_channel()),
            )
            .with_context(|| format!("Couldn't open block device {}", &child.name));
        if let Err(err) = open_result {
            // Ignore failures to open any particular block device and just omit it from the
            // listing.
            warn!("{}", err);
            continue;
        }

        block_devs.push(DevBlockDevice { node: block_client });
    }
    Ok(block_devs)
}
/// Given a directory handle representing the root of a device tree (i.e. open handle to "/dev"),
/// open all block devices in `/dev/class/block/*` and return them as DevBlockDevice instances.
Given a directory handle representing the root of a device tree ,
open all block devices in `/dev/class/block` and return them as DevBlockDevice instances.
Given a directory handle representing the root of a device tree open all block devices in ` / dev / class / block ` and return them as DevBlockDevice instances .
async fn all_block_devices(dev_root_dir: &DirectoryProxy) -> Result<Vec<DevBlockDevice>, Error> {
    let (block_dir_client, block_dir_server) =
        fidl::endpoints::create_proxy::<DirectoryMarker>().context("create channel pair")?;
    dev_root_dir
        .open(
            OPEN_FLAG_DIRECTORY | OPEN_RW, // flags
            MODE_TYPE_DIRECTORY,           // mode
            "class/block",                 // path
            ServerEnd::new(block_dir_server.into_channel()),
        )
        .context("open() error")?;
    let dirents = files_async::readdir(&block_dir_client)
        .await
        .context("list children of block device dir")?;
    let mut block_devs = Vec::new();
    for child in dirents {
        let (block_client, block_server) =
            fidl::endpoints::create_proxy::<NodeMarker>().context("create Node channel pair")?;
        let open_result = block_dir_client
            .open(
                OPEN_RW,
                MODE_TYPE_SERVICE,
                &child.name,
                ServerEnd::new(block_server.into_channel()),
            )
            .with_context(|| format!("Couldn't open block device {}", &child.name));
        if let Err(err) = open_result {
            // Ignore failures to open any particular block device and just omit it from the
            // listing.
            warn!("{}", err);
            continue;
        }
        block_devs.push(DevBlockDevice { node: block_client });
    }
    Ok(block_devs)
}
async fn all_block_devices ( dev_root_dir : & DirectoryProxy ) -> Result < Vec < DevBlockDevice > , Error > { let ( block_dir_client , block_dir_server ) = fidl :: endpoints :: create_proxy :: < DirectoryMarker > ( ) . context ( " " ) ? ; dev_root_dir . open ( OPEN_FLAG_DIRECTORY | OPEN_RW , // flags MODE_TYPE_DIRECTORY , // mode " " , // path ServerEnd :: new ( block_dir_server . into_channel ( ) ) , ) . context ( " " ) ? ; let dirents = files_async :: readdir ( & block_dir_client ) . await . context ( " " ) ? ; let mut block_devs = Vec :: new ( ) ; for child in dirents { let ( block_client , block_server ) = fidl :: endpoints :: create_proxy :: < NodeMarker > ( ) . context ( " " ) ? ; let open_result = block_dir_client . open ( OPEN_RW , MODE_TYPE_SERVICE , & child . name , ServerEnd :: new ( block_server . into_channel ( ) ) , ) . with_context ( | | format ! ( " " child name ) ) ; if let Err ( err ) = open_result { // Ignore failures to open any particular block device and just omit it from the // listing. warn ! ( " " err ) ; continue ; } block_devs . push ( DevBlockDevice { node : block_client } ) ; } Ok ( block_devs ) }
Given a directory handle representing the root of a device tree (i.e.
Given a directory handle representing the root of a device tree ( i . e .
dev_root_dir
&DirectoryProxy
dev_root_dir
&DirectoryProxy