Skip to main content

ftui_runtime/
voi_telemetry.rs

1#![forbid(unsafe_code)]
2
3//! VOI debug telemetry snapshots for runtime introspection.
4
5use std::sync::{LazyLock, RwLock};
6
7use crate::voi_sampling::VoiSamplerSnapshot;
8
9static INLINE_AUTO_VOI_SNAPSHOT: LazyLock<RwLock<Option<VoiSamplerSnapshot>>> =
10    LazyLock::new(|| RwLock::new(None));
11
12/// Store the latest inline-auto VOI snapshot.
13pub fn set_inline_auto_voi_snapshot(snapshot: Option<VoiSamplerSnapshot>) {
14    if let Ok(mut guard) = INLINE_AUTO_VOI_SNAPSHOT.write() {
15        *guard = snapshot;
16    }
17}
18
19/// Fetch the latest inline-auto VOI snapshot.
20#[must_use]
21pub fn inline_auto_voi_snapshot() -> Option<VoiSamplerSnapshot> {
22    INLINE_AUTO_VOI_SNAPSHOT
23        .read()
24        .ok()
25        .and_then(|guard| guard.clone())
26}
27
28/// Clear any stored inline-auto VOI snapshot.
29pub fn clear_inline_auto_voi_snapshot() {
30    set_inline_auto_voi_snapshot(None);
31}