Maxable

Trait Maxable 

Source
pub trait Maxable:
    MaxableSealed
    + Sized
    + Copy
    + Ord {
    // Required method
    fn max_across(items: impl IntoIterator<Item = Self>) -> Option<Self>;
}
Expand description

Marker for newtypes that can be reduced by max across a group.

Implemented by PeakNs (max-of-peak is the worst high-water mark any contributor saw across its lifetime), PeakBytes (the byte-typed twin of PeakNs; max of per-task hiwater_rss / hiwater_vm), GaugeNs (max-of-gauge is the longest current value in the bucket — distinct temporal window: each gauge is a fresh sample at capture time, not a lifetime accumulator), and GaugeCount (max-of-count is the biggest current value in the bucket — same gauge-window caveat).

Deliberately NOT implemented by Summable cumulative counters (MonotonicCount / MonotonicNs / ClockTicks / Bytes): max-across-snapshots on a thread-lifetime accumulator reduces to “the value of the last snapshot,” because each snapshot’s reading dominates every prior reading by construction (the kernel only ever raises a lifetime counter). That gives a reduction whose “maximum” is the most-recent reading rather than a worst single window — useful as a sanity bound, but rendering it alongside per-thread peaks invites confusion. If a future metric truly needs the lifetime-integrated max of a cumulative counter, introduce a dedicated peak-of-counter newtype rather than re-adding Maxable to a Summable type. Deliberately NOT implemented by ordinals (those carry a [min, max] range, not a single max), nor by CategoricalString (string max has no useful semantic), nor by CpuSet (the affinity reduction is a custom summary, not a bare max).

Sealed via sealed::MaxableSealed: a downstream crate cannot write impl Maxable for CategoricalString because the sealed supertrait is private to this module.

max_across returns Option<Self>: None for an empty iterator (so callers can distinguish “no contributors” from “max was zero — the worst reading any contributor reported happened to be the additive identity”), Some(largest) otherwise. Aggregation callers that want to preserve the pre-Option contract collapse None to the type’s default() value at the call site.

Required Methods§

Source

fn max_across(items: impl IntoIterator<Item = Self>) -> Option<Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§