sl4f_lib/diagnostics/
facade.rsuse crate::diagnostics::types::SnapshotInspectArgs;
use anyhow::Error;
use diagnostics_reader::{ArchiveReader, Inspect, RetryConfig};
use fidl_fuchsia_diagnostics::ArchiveAccessorMarker;
use fuchsia_component::client;
use serde_json::Value;
const BATCH_RETRIEVAL_TIMEOUT_SECONDS: i64 = 300;
#[derive(Debug)]
pub struct DiagnosticsFacade {}
impl DiagnosticsFacade {
pub fn new() -> DiagnosticsFacade {
DiagnosticsFacade {}
}
pub async fn snapshot_inspect(&self, args: SnapshotInspectArgs) -> Result<Value, Error> {
let service_path = format!("/svc/{}", args.service_name);
let proxy =
client::connect_to_protocol_at_path::<ArchiveAccessorMarker>(&service_path).unwrap();
let value = ArchiveReader::new()
.retry(RetryConfig::never())
.with_archive(proxy)
.add_selectors(args.selectors.into_iter())
.with_batch_retrieval_timeout_seconds(BATCH_RETRIEVAL_TIMEOUT_SECONDS)
.snapshot_raw::<Inspect, serde_json::Value>()
.await?;
Ok(value)
}
}