Skip to main content

ObservableMetric

Enum ObservableMetric 

Source
pub enum ObservableMetric<T> {
    Measured(T),
    Proxy(T),
    Unobservable(&'static str),
}
Expand description

Truthful observability wrapper separating directly measured samples, proxy estimates, and explicitly unobservable metrics (never faking zero).

Variants§

§

Measured(T)

Directly measured from real hardware, compositor, or instrumented runtime counters.

§

Proxy(T)

Proxy estimate (such as callback or submission timing) rather than compositor proof.

§

Unobservable(&'static str)

Metric is unavailable on this host/backend and MUST serialize as null with an explicit reason.

Implementations§

Source§

impl<T> ObservableMetric<T>

Inspection helpers for ObservableMetric<T>.

Source

pub const fn is_measured(&self) -> bool

Returns true when this metric holds a directly measured sample.

§Arguments
  • &Self - Metric reference.
§Returns
  • bool - true only for Measured.
Source

pub const fn is_proxy(&self) -> bool

Returns true when this metric holds a proxy estimate.

§Arguments
  • &Self - Metric reference.
§Returns
  • bool - true only for Proxy.
Source

pub const fn is_unobservable(&self) -> bool

Returns true when this metric is explicitly unobservable.

§Arguments
  • &Self - Metric reference.
§Returns
  • bool - true only for Unobservable.
Source

pub const fn status_str(&self) -> &'static str

Returns the canonical wire status string ("measured", "proxy", or "unobservable").

§Arguments
  • &Self - Metric reference.
§Returns
  • &'static str - Canonical metric status tag.
Source

pub const fn value_ref(&self) -> Option<&T>

Returns a reference to the underlying value when Measured or Proxy, or None when Unobservable.

§Arguments
  • &Self - Metric reference.
§Returns
  • Option<&T> - Inner value reference when available.
Source

pub const fn measured_ref(&self) -> Option<&T>

Returns a reference to the directly measured value only (None for Proxy or Unobservable).

§Arguments
  • &Self - Metric reference.
§Returns
  • Option<&T> - Directly measured value reference.
Source

pub const fn unobservable_reason(&self) -> Option<&'static str>

Returns the diagnostic reason when this metric is Unobservable.

§Arguments
  • &Self - Metric reference.
§Returns
  • Option<&'static str> - Unobservability reason if unavailable.

Trait Implementations§

Source§

impl<T: Clone> Clone for ObservableMetric<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for ObservableMetric<T>

Source§

impl<T: Debug> Debug for ObservableMetric<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for ObservableMetric<T>

Default unobservable state ensuring missing metrics never initialize as fake zero.

Source§

fn default() -> Self

Creates an explicitly unobservable metric placeholder.

§Returns
  • Self - ObservableMetric::Unobservable(UNOBSERVABLE_NOT_COLLECTED).
Source§

impl<T: Eq> Eq for ObservableMetric<T>

Source§

impl<T: Hash> Hash for ObservableMetric<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for ObservableMetric<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T> Serialize for ObservableMetric<T>
where T: Serialize,

Truthful JSON serialization emitting explicit status, value (null when unobservable), and reason.

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes this metric without ever replacing unobservable data with fake zero.

§Arguments
  • &Self - Metric reference.
  • S - Active serializer.
§Returns
  • Result<S::Ok, S::Error> - Serialized object representation.
Source§

impl<T: PartialEq> StructuralPartialEq for ObservableMetric<T>

Auto Trait Implementations§

§

impl<T> Forget for ObservableMetric<T>

§

impl<T> Freeze for ObservableMetric<T>
where T: Freeze, &'static str: Freeze,

§

impl<T> Move for ObservableMetric<T>

§

impl<T> RefUnwindSafe for ObservableMetric<T>
where T: RefUnwindSafe,

§

impl<T> Send for ObservableMetric<T>
where T: Send, &'static str: Send,

§

impl<T> Sync for ObservableMetric<T>
where T: Sync,

§

impl<T> Unpin for ObservableMetric<T>
where T: Unpin, &'static str: Unpin,

§

impl<T> UnsafeUnpin for ObservableMetric<T>
where T: UnsafeUnpin, &'static str: UnsafeUnpin,

§

impl<T> UnwindSafe for ObservableMetric<T>
where T: UnwindSafe, &'static str: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.