sl4f_lib/diagnostics/
facade.rs1use crate::diagnostics::types::SnapshotInspectArgs;
6use anyhow::Error;
7use diagnostics_reader::{ArchiveReader, RetryConfig};
8use fidl_fuchsia_diagnostics::ArchiveAccessorMarker;
9use fuchsia_component::client;
10use serde_json::Value;
11
12const BATCH_RETRIEVAL_TIMEOUT_SECONDS: i64 = 300;
15
16#[derive(Debug)]
18pub struct DiagnosticsFacade {}
19
20impl DiagnosticsFacade {
21 pub fn new() -> DiagnosticsFacade {
22 DiagnosticsFacade {}
23 }
24
25 pub async fn snapshot_inspect(&self, args: SnapshotInspectArgs) -> Result<Value, Error> {
26 let service_path = format!("/svc/{}", args.service_name);
27 let proxy =
28 client::connect_to_protocol_at_path::<ArchiveAccessorMarker>(&service_path).unwrap();
29 let value = ArchiveReader::inspect()
30 .retry(RetryConfig::never())
31 .with_archive(proxy)
32 .add_selectors(args.selectors.into_iter())
33 .with_batch_retrieval_timeout_seconds(BATCH_RETRIEVAL_TIMEOUT_SECONDS)
34 .snapshot_raw::<serde_json::Value>()
35 .await?;
36 Ok(value)
37 }
38}