/// Find any custom artifact users under the test realm and report them via sender.
Find any custom artifact users under the test realm and report them via sender.
Find any custom artifact users under the test realm and report them via sender .
async fn report_custom_artifacts(
        &mut self,
        sender: &mut mpsc::Sender<Result<FidlSuiteEvent, LaunchError>>,
    ) -> Result<(), Error> {
        let artifact_storage_admin = connect_to_protocol::<fsys::StorageAdminMarker>()?;
        let root_moniker = format!("./{}:{}", TESTS_COLLECTION, self.instance.root.child_name());
        let (iterator, iter_server) = create_proxy::<fsys::StorageIteratorMarker>()?;
        artifact_storage_admin
            .list_storage_in_realm(&root_moniker, iter_server)
            .await?
            .map_err(|e| format_err!("Error listing storage users in test realm: {:?}", e))?;
        let mut stream = stream_fn(move || iterator.next());
        while let Some(storage_moniker) = stream.try_next().await? {
            let (node, server) = fidl::endpoints::create_endpoints::<fio::NodeMarker>()?;
            let directory: ClientEnd<fio::DirectoryMarker> = node.into_channel().into();
            artifact_storage_admin.open_component_storage(
                &storage_moniker,
                fio::OPEN_RIGHT_READABLE,
                fio::MODE_TYPE_DIRECTORY,
                server,
            )?;
            let (event_client, event_server) = zx::EventPair::create()?;
            self.custom_artifact_tokens.push(event_server);
            // Monikers should be reported relative to the test root, so strip away the wrapping
            // components from the path.
            let moniker_parsed =
                moniker::RelativeMoniker::try_from(storage_moniker.as_str()).unwrap();
            let down_path = moniker_parsed
                .down_path()
                .iter()
                .skip(3)
                .map(Clone::clone)
                .collect::<Vec<moniker::ChildMoniker>>();
            let moniker_relative_to_test_root = moniker::RelativeMoniker::new(vec![], down_path);
            sender
                .send(Ok(SuiteEvents::suite_custom_artifact(ftest_manager::CustomArtifact {
                    directory_and_token: Some(ftest_manager::DirectoryAndToken {
                        directory,
                        token: event_client,
                    }),
                    component_moniker: Some(
                        moniker_relative_to_test_root.to_string_without_instances(),
                    ),
                    ..ftest_manager::CustomArtifact::EMPTY
                })
                .into()))
                .await
                .unwrap();
        }
        Ok(())
    }
async fn report_custom_artifacts ( & mut self , sender : & mut mpsc :: Sender < Result < FidlSuiteEvent , LaunchError > > , ) -> Result < ( ) , Error > { let artifact_storage_admin = connect_to_protocol :: < fsys :: StorageAdminMarker > ( ) ? ; let root_moniker = format ! ( " " TESTS_COLLECTION self instance root child_name ( ) ) ; let ( iterator , iter_server ) = create_proxy :: < fsys :: StorageIteratorMarker > ( ) ? ; artifact_storage_admin . list_storage_in_realm ( & root_moniker , iter_server ) . await ? . map_err ( | e | format_err ! ( " " e ) ) ? ; let mut stream = stream_fn ( move | | iterator . next ( ) ) ; while let Some ( storage_moniker ) = stream . try_next ( ) . await ? { let ( node , server ) = fidl :: endpoints :: create_endpoints :: < fio :: NodeMarker > ( ) ? ; let directory : ClientEnd < fio :: DirectoryMarker > = node . into_channel ( ) . into ( ) ; artifact_storage_admin . open_component_storage ( & storage_moniker , fio :: OPEN_RIGHT_READABLE , fio :: MODE_TYPE_DIRECTORY , server , ) ? ; let ( event_client , event_server ) = zx :: EventPair :: create ( ) ? ; self . custom_artifact_tokens . push ( event_server ) ; // Monikers should be reported relative to the test root, so strip away the wrapping // components from the path. let moniker_parsed = moniker :: RelativeMoniker :: try_from ( storage_moniker . as_str ( ) ) . unwrap ( ) ; let down_path = moniker_parsed . down_path ( ) . iter ( ) . skip ( 3 ) . map ( Clone :: clone ) . collect :: < Vec < moniker :: ChildMoniker > > ( ) ; let moniker_relative_to_test_root = moniker :: RelativeMoniker :: new ( vec ! [ ] , down_path ) ; sender . send ( Ok ( SuiteEvents :: suite_custom_artifact ( ftest_manager :: CustomArtifact { directory_and_token : Some ( ftest_manager :: DirectoryAndToken { directory , token : event_client , } ) , component_moniker : Some ( moniker_relative_to_test_root . to_string_without_instances ( ) , ) , .. ftest_manager :: CustomArtifact :: EMPTY } ) . into ( ) ) ) . await . unwrap ( ) ; } Ok ( ( ) ) }
Find any custom artifact users under the test realm and report them via sender.
Find any custom artifact users under the test realm and report them via sender .
&mut self
sender
&mut mpsc::Sender<Result<FidlSuiteEvent, LaunchError>>