1use anyhow::Error;
6use fuchsia_inspect::{Inspector, LazyNode, Node};
7use fuchsia_sync::Mutex;
8use futures::future::BoxFuture;
9use once_cell::sync::Lazy;
10
11fn root() -> Node {
13 #[cfg(target_os = "fuchsia")]
14 static FXFS_ROOT_NODE: Lazy<Mutex<fuchsia_inspect::Node>> =
15 Lazy::new(|| Mutex::new(fuchsia_inspect::component::inspector().root().clone_weak()));
16 #[cfg(not(target_os = "fuchsia"))]
17 static FXFS_ROOT_NODE: Lazy<Mutex<Node>> = Lazy::new(|| Mutex::new(Node::default()));
18
19 FXFS_ROOT_NODE.lock().clone_weak()
20}
21
22pub fn detail() -> Node {
24 static DETAIL_NODE: Lazy<Mutex<Node>> =
25 Lazy::new(|| Mutex::new(root().create_child("fs.detail")));
26
27 DETAIL_NODE.lock().clone_weak()
28}
29
30pub fn register_fs(
31 populate_stores_fn: impl Fn() -> BoxFuture<'static, Result<Inspector, Error>>
32 + Sync
33 + Send
34 + 'static,
35) -> LazyNode {
36 root().create_lazy_child("stores", populate_stores_fn)
37}