pub async fn serve_snapshot_results(
        self,
        batch_iterator_channel: fasync::Channel,
        format: fidl_fuchsia_diagnostics::Format,
    ) -> Result<(), Error> {
        // We must fetch the repositories in a closure to prevent the
        // repository mutex-guard from leaking into futures.
        let inspect_repo_data = {
            let locked_inspect_repo = self.inspect_repo.read().unwrap();
            locked_inspect_repo.fetch_data()
        };

        let mut stream = fidl_fuchsia_diagnostics::BatchIteratorRequestStream::from_channel(
            batch_iterator_channel,
        );

        let inspect_repo_length = inspect_repo_data.len();
        let mut inspect_repo_iter = inspect_repo_data.into_iter();
        let mut iter = 0;
        let max = (inspect_repo_length - 1 / IN_MEMORY_SNAPSHOT_LIMIT) + 1;
        while let Some(req) = stream.try_next().await? {
            match req {
                fidl_fuchsia_diagnostics::BatchIteratorRequest::GetNext { responder } => {
                    if iter < max {
                        let snapshot_batch: Vec<UnpopulatedInspectDataContainer> =
                            (&mut inspect_repo_iter).take(IN_MEMORY_SNAPSHOT_LIMIT).collect();

                        iter = iter + 1;

                        // Asynchronously populate data containers with snapshots of relevant
                        // inspect hierarchies.
                        let pumped_inspect_data_results =
                            ReaderServer::pump_inspect_data(snapshot_batch).await;

                        // Apply selector filtering to all snapshot inspect hierarchies in the batch.
                        let batch_hierarchy_data =
                            ReaderServer::filter_snapshots(pumped_inspect_data_results);

                        let formatted_content: Vec<
                            Result<fidl_fuchsia_diagnostics::FormattedContent, Error>,
                        > = ReaderServer::format_hierarchies(format, batch_hierarchy_data);

                        let filtered_results: Vec<fidl_fuchsia_diagnostics::FormattedContent> =
                            formatted_content.into_iter().filter_map(Result::ok).collect();
                        responder.send(&mut Ok(filtered_results)).unwrap();
                    } else {
                        responder.send(&mut Ok(Vec::new())).unwrap();
                    }
                }
            }
        }

        Ok(())
    }
/// Takes a BatchIterator server channel and starts serving snapshotted
/// Inspect hierarchies to clients as vectors of FormattedContent. The hierarchies
/// are served in batches of `IN_MEMORY_SNAPSHOT_LIMIT` at a time, and snapshots of
/// diagnostics data aren't taken until a component is included in
Takes a BatchIterator server channel and starts serving snapshotted
Inspect hierarchies to clients as vectors of FormattedContent. The hierarchies
are served in batches of `IN_MEMORY_SNAPSHOT_LIMIT` at a time, and snapshots of
diagnostics data aren't taken until a component is included in
Takes a BatchIterator server channel and starts serving snapshotted Inspect hierarchies to clients as vectors of FormattedContent . The hierarchies are served in batches of ` IN_MEMORY_SNAPSHOT_LIMIT ` at a time and snapshots of diagnostics data aren ' t taken until a component is included in
pub async fn serve_snapshot_results(
        self,
        batch_iterator_channel: fasync::Channel,
        format: fidl_fuchsia_diagnostics::Format,
    ) -> Result<(), Error> {
        // We must fetch the repositories in a closure to prevent the
        // repository mutex-guard from leaking into futures.
        let inspect_repo_data = {
            let locked_inspect_repo = self.inspect_repo.read().unwrap();
            locked_inspect_repo.fetch_data()
        };
        let mut stream = fidl_fuchsia_diagnostics::BatchIteratorRequestStream::from_channel(
            batch_iterator_channel,
        );
        let inspect_repo_length = inspect_repo_data.len();
        let mut inspect_repo_iter = inspect_repo_data.into_iter();
        let mut iter = 0;
        let max = (inspect_repo_length - 1 / IN_MEMORY_SNAPSHOT_LIMIT) + 1;
        while let Some(req) = stream.try_next().await? {
            match req {
                fidl_fuchsia_diagnostics::BatchIteratorRequest::GetNext { responder } => {
                    if iter < max {
                        let snapshot_batch: Vec<UnpopulatedInspectDataContainer> =
                            (&mut inspect_repo_iter).take(IN_MEMORY_SNAPSHOT_LIMIT).collect();
                        iter = iter + 1;
                        // Asynchronously populate data containers with snapshots of relevant
                        // inspect hierarchies.
                        let pumped_inspect_data_results =
                            ReaderServer::pump_inspect_data(snapshot_batch).await;
                        // Apply selector filtering to all snapshot inspect hierarchies in the batch.
                        let batch_hierarchy_data =
                            ReaderServer::filter_snapshots(pumped_inspect_data_results);
                        let formatted_content: Vec<
                            Result<fidl_fuchsia_diagnostics::FormattedContent, Error>,
                        > = ReaderServer::format_hierarchies(format, batch_hierarchy_data);
                        let filtered_results: Vec<fidl_fuchsia_diagnostics::FormattedContent> =
                            formatted_content.into_iter().filter_map(Result::ok).collect();
                        responder.send(&mut Ok(filtered_results)).unwrap();
                    } else {
                        responder.send(&mut Ok(Vec::new())).unwrap();
                    }
                }
            }
        }
        Ok(())
    }
pub async fn serve_snapshot_results ( self , batch_iterator_channel : fasync :: Channel , format : fidl_fuchsia_diagnostics :: Format , ) -> Result < ( ) , Error > { // We must fetch the repositories in a closure to prevent the // repository mutex-guard from leaking into futures. let inspect_repo_data = { let locked_inspect_repo = self . inspect_repo . read ( ) . unwrap ( ) ; locked_inspect_repo . fetch_data ( ) } ; let mut stream = fidl_fuchsia_diagnostics :: BatchIteratorRequestStream :: from_channel ( batch_iterator_channel , ) ; let inspect_repo_length = inspect_repo_data . len ( ) ; let mut inspect_repo_iter = inspect_repo_data . into_iter ( ) ; let mut iter = 0 ; let max = ( inspect_repo_length - 1 / IN_MEMORY_SNAPSHOT_LIMIT ) + 1 ; while let Some ( req ) = stream . try_next ( ) . await ? { match req { fidl_fuchsia_diagnostics :: BatchIteratorRequest :: GetNext { responder } => { if iter < max { let snapshot_batch : Vec < UnpopulatedInspectDataContainer > = ( & mut inspect_repo_iter ) . take ( IN_MEMORY_SNAPSHOT_LIMIT ) . collect ( ) ; iter = iter + 1 ; // Asynchronously populate data containers with snapshots of relevant // inspect hierarchies. let pumped_inspect_data_results = ReaderServer :: pump_inspect_data ( snapshot_batch ) . await ; // Apply selector filtering to all snapshot inspect hierarchies in the batch. let batch_hierarchy_data = ReaderServer :: filter_snapshots ( pumped_inspect_data_results ) ; let formatted_content : Vec < Result < fidl_fuchsia_diagnostics :: FormattedContent , Error > , > = ReaderServer :: format_hierarchies ( format , batch_hierarchy_data ) ; let filtered_results : Vec < fidl_fuchsia_diagnostics :: FormattedContent > = formatted_content . into_iter ( ) . filter_map ( Result :: ok ) . collect ( ) ; responder . send ( & mut Ok ( filtered_results ) ) . unwrap ( ) ; } else { responder . send ( & mut Ok ( Vec :: new ( ) ) ) . unwrap ( ) ; } } } } Ok ( ( ) ) }
Takes a BatchIterator server channel and starts serving snapshotted
Inspect hierarchies to clients as vectors of FormattedContent.
Takes a BatchIterator server channel and starts serving snapshotted Inspect hierarchies to clients as vectors of FormattedContent .
self
batch_iterator_channel
fasync::Channel
format
fidl_fuchsia_diagnostics::Format