pub async fn populate_data_map(&mut self, inspect_proxy: &DirectoryProxy) -> Result<(), Error> {
        // TODO(36762): Use a streaming and bounded readdir API when available to avoid
        // being hung.
        for entry in files_async::readdir_recursive(inspect_proxy).await?.into_iter() {
            // We are only currently interested in inspect VMO files (root.inspect) and
            // inspect services.
            if let Some(proxy) = self.maybe_load_service::<TreeMarker>(inspect_proxy, &entry)? {
                let maybe_vmo = proxy.get_content().await?.buffer.map(|b| b.vmo);
                self.maybe_add(
                    Path::new(&entry.name).file_name().unwrap().to_string_lossy().to_string(),
                    Data::Tree(proxy, maybe_vmo),
                );
            }
            if let Some(proxy) = self.maybe_load_service::<InspectMarker>(inspect_proxy, &entry)? {
                self.maybe_add(
                    Path::new(&entry.name).file_name().unwrap().to_string_lossy().to_string(),
                    Data::DeprecatedFidl(proxy),
                );
            }
            if !entry.name.ends_with(".inspect") || entry.kind != files_async::DirentKind::File {
                continue;
            }

            let file_proxy = match io_util::open_file(
                inspect_proxy,
                Path::new(&entry.name),
                io_util::OPEN_RIGHT_READABLE,
            ) {
                Ok(proxy) => proxy,
                Err(_) => {
                    continue;
                }
            };

            // Obtain the vmo backing any VmoFiles.
            match file_proxy.describe().await {
                Ok(nodeinfo) => match nodeinfo {
                    NodeInfo::Vmofile(vmofile) => {
                        self.maybe_add(
                            Path::new(&entry.name)
                                .file_name()
                                .unwrap()
                                .to_string_lossy()
                                .to_string(),
                            Data::Vmo(vmofile.vmo),
                        );
                    }
                    NodeInfo::File(_) => {
                        let contents = io_util::read_file_bytes(&file_proxy).await?;
                        self.maybe_add(
                            Path::new(&entry.name)
                                .file_name()
                                .unwrap()
                                .to_string_lossy()
                                .to_string(),
                            Data::File(contents),
                        );
                    }
                    ty @ _ => {
                        eprintln!(
                            "found an inspect file '{}' of unexpected type {:?}",
                            &entry.name, ty
                        );
                    }
                },
                Err(_) => {}
            }
        }

        Ok(())
    }
/// Searches the directory specified by inspect_directory_proxy for
/// .inspect files and populates the `inspect_data_map` with the found VMOs.
Searches the directory specified by inspect_directory_proxy for
.inspect files and populates the `inspect_data_map` with the found VMOs.
Searches the directory specified by inspect_directory_proxy for . inspect files and populates the ` inspect_data_map ` with the found VMOs .
pub async fn populate_data_map(&mut self, inspect_proxy: &DirectoryProxy) -> Result<(), Error> {
        // TODO(36762): Use a streaming and bounded readdir API when available to avoid
        // being hung.
        for entry in files_async::readdir_recursive(inspect_proxy).await?.into_iter() {
            // We are only currently interested in inspect VMO files (root.inspect) and
            // inspect services.
            if let Some(proxy) = self.maybe_load_service::<TreeMarker>(inspect_proxy, &entry)? {
                let maybe_vmo = proxy.get_content().await?.buffer.map(|b| b.vmo);
                self.maybe_add(
                    Path::new(&entry.name).file_name().unwrap().to_string_lossy().to_string(),
                    Data::Tree(proxy, maybe_vmo),
                );
            }
            if let Some(proxy) = self.maybe_load_service::<InspectMarker>(inspect_proxy, &entry)? {
                self.maybe_add(
                    Path::new(&entry.name).file_name().unwrap().to_string_lossy().to_string(),
                    Data::DeprecatedFidl(proxy),
                );
            }
            if !entry.name.ends_with(".inspect") || entry.kind != files_async::DirentKind::File {
                continue;
            }
            let file_proxy = match io_util::open_file(
                inspect_proxy,
                Path::new(&entry.name),
                io_util::OPEN_RIGHT_READABLE,
            ) {
                Ok(proxy) => proxy,
                Err(_) => {
                    continue;
                }
            };
            // Obtain the vmo backing any VmoFiles.
            match file_proxy.describe().await {
                Ok(nodeinfo) => match nodeinfo {
                    NodeInfo::Vmofile(vmofile) => {
                        self.maybe_add(
                            Path::new(&entry.name)
                                .file_name()
                                .unwrap()
                                .to_string_lossy()
                                .to_string(),
                            Data::Vmo(vmofile.vmo),
                        );
                    }
                    NodeInfo::File(_) => {
                        let contents = io_util::read_file_bytes(&file_proxy).await?;
                        self.maybe_add(
                            Path::new(&entry.name)
                                .file_name()
                                .unwrap()
                                .to_string_lossy()
                                .to_string(),
                            Data::File(contents),
                        );
                    }
                    ty @ _ => {
                        eprintln!(
                            "found an inspect file '{}' of unexpected type {:?}",
                            &entry.name, ty
                        );
                    }
                },
                Err(_) => {}
            }
        }
        Ok(())
    }
pub async fn populate_data_map ( & mut self , inspect_proxy : & DirectoryProxy ) -> Result < ( ) , Error > { // TODO(36762): Use a streaming and bounded readdir API when available to avoid // being hung. for entry in files_async :: readdir_recursive ( inspect_proxy ) . await ? . into_iter ( ) { // We are only currently interested in inspect VMO files (root.inspect) and // inspect services. if let Some ( proxy ) = self . maybe_load_service :: < TreeMarker > ( inspect_proxy , & entry ) ? { let maybe_vmo = proxy . get_content ( ) . await ? . buffer . map ( | b | b . vmo ) ; self . maybe_add ( Path :: new ( & entry . name ) . file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) , Data :: Tree ( proxy , maybe_vmo ) , ) ; } if let Some ( proxy ) = self . maybe_load_service :: < InspectMarker > ( inspect_proxy , & entry ) ? { self . maybe_add ( Path :: new ( & entry . name ) . file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) , Data :: DeprecatedFidl ( proxy ) , ) ; } if ! entry . name . ends_with ( " " ) || entry . kind != files_async :: DirentKind :: File { continue ; } let file_proxy = match io_util :: open_file ( inspect_proxy , Path :: new ( & entry . name ) , io_util :: OPEN_RIGHT_READABLE , ) { Ok ( proxy ) => proxy , Err ( _ ) => { continue ; } } ; // Obtain the vmo backing any VmoFiles. match file_proxy . describe ( ) . await { Ok ( nodeinfo ) => match nodeinfo { NodeInfo :: Vmofile ( vmofile ) => { self . maybe_add ( Path :: new ( & entry . name ) . file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) , Data :: Vmo ( vmofile . vmo ) , ) ; } NodeInfo :: File ( _ ) => { let contents = io_util :: read_file_bytes ( & file_proxy ) . await ? ; self . maybe_add ( Path :: new ( & entry . name ) . file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) , Data :: File ( contents ) , ) ; } ty @ _ => { eprintln ! ( " " entry name ty ) ; } } , Err ( _ ) => { } } } Ok ( ( ) ) }
Searches the directory specified by inspect_directory_proxy for
.inspect files and populates the `inspect_data_map` with the found VMOs.
Searches the directory specified by inspect_directory_proxy for . inspect files and populates the ` inspect_data_map ` with the found VMOs .
&mut self
inspect_proxy
&DirectoryProxy