pub struct MeasurementSummary { /* private fields */ }Expand description
Canonical shared arithmetic for local diagnostic summaries and distributions.
Re-exported so callers can name returned summaries without selecting a separate Metrics dependency. This is the shared type, with no local wrapper or arithmetic. Saturating summary of observations in one consumer-selected unit.
Count and total saturate independently at u64::MAX. Treat either counter
at that value as unavailable for exact interval arithmetic, including when
reached exactly. Latest and maximum remain individual observations after
saturation. Empty and measured zero are distinct states.
Consumers establish identity and reset boundaries before comparing snapshots. The summary does not decide whether observations overlap or are additive.
Implementations§
Source§impl MeasurementSummary
impl MeasurementSummary
Sourcepub const EMPTY: MeasurementSummary
pub const EMPTY: MeasurementSummary
Empty summary, with no latest or maximum observation.
Sourcepub const fn record(&mut self, value: u64)
pub const fn record(&mut self, value: u64)
Record one completed observation, including zero.
Every observation must use the same unit as earlier observations.
Sourcepub const fn samples(self) -> u64
pub const fn samples(self) -> u64
Number of completed samples, saturating independently of the total.
Sourcepub const fn total(self) -> u64
pub const fn total(self) -> u64
Sum of all observations, saturating independently of the sample count.
Sourcepub const fn mean(self) -> Result<Option<u64>, MeasurementMeanError>
pub const fn mean(self) -> Result<Option<u64>, MeasurementMeanError>
Integer mean in the observation’s unit, rounded down, or None if empty.
§Errors
Returns MeasurementMeanError when either counter is at u64::MAX,
including an exactly reached cap. Uses the same contract as checked_mean.
Trait Implementations§
Source§impl Clone for MeasurementSummary
impl Clone for MeasurementSummary
Source§fn clone(&self) -> MeasurementSummary
fn clone(&self) -> MeasurementSummary
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more