Common/Diagnostic/GetAllDiagnostics.rs
1//! # GetAllDiagnostics Effect
2//!
3//! Defines the `ActionEffect` for retrieving all diagnostics from the host.
4
5use std::sync::Arc;
6
7use serde_json::Value;
8
9use super::DiagnosticManager::DiagnosticManager;
10use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
11
12/// Creates an effect that, when executed, will retrieve all diagnostics
13/// currently managed by the host, with an option to filter for a specific
14/// resource URI.
15///
16/// It uses the `DiagnosticManager` capability from the environment to perform
17/// the operation.
18///
19/// # Parameters
20/// * `ResourceURIFilterOption`: An `Option<Value>` containing a serialized
21/// `UriComponents` DTO. If `Some`, only diagnostics for that URI will be
22/// returned. If `None`, all diagnostics for all resources are returned.
23///
24/// # Returns
25/// An `ActionEffect` that resolves with a `serde_json::Value` representing an
26/// array of `[UriComponents, MarkerDataDTO[]]` tuples.
27pub fn GetAllDiagnostics(
28 ResourceURIFilterOption:Option<Value>,
29) -> ActionEffect<Arc<dyn DiagnosticManager>, CommonError, Value> {
30 ActionEffect::New(Arc::new(move |Manager:Arc<dyn DiagnosticManager>| {
31 let FilterClone = ResourceURIFilterOption.clone();
32
33 Box::pin(async move { Manager.GetAllDiagnostics(FilterClone).await })
34 }))
35}