pub trait PhaseMapExt<T> {
// Required methods
fn zip_per_phase<U, R>(
&self,
other: &BTreeMap<Phase, U>,
f: impl FnMut(T, U) -> R,
) -> BTreeMap<Phase, R>
where T: Copy,
U: Copy;
fn ratio_across_phases<'v>(
&self,
verdict: &'v mut Verdict,
label: impl Into<String>,
earlier: Phase,
later: Phase,
) -> CrossPhaseRatio<'v, T>
where T: Copy + Into<f64> + Display;
}Expand description
Extension trait that lets a pre-reduced per-phase map
(typically the output of SeriesField::counter_delta_per_phase,
SeriesField::last_per_phase, or
SeriesField::first_per_phase) compose with the
cross-phase comparator chain SeriesField::ratio_across_phases
exposes — without re-projecting the per-phase values back
through a synthetic SeriesField.
Also surfaces Self::zip_per_phase so two per-phase maps fold
element-wise into a derived per-phase map (e.g. a cross-LLC
dispatch fraction from two counter-delta maps).
Required Methods§
Sourcefn zip_per_phase<U, R>(
&self,
other: &BTreeMap<Phase, U>,
f: impl FnMut(T, U) -> R,
) -> BTreeMap<Phase, R>
fn zip_per_phase<U, R>( &self, other: &BTreeMap<Phase, U>, f: impl FnMut(T, U) -> R, ) -> BTreeMap<Phase, R>
Fold two per-phase maps element-wise on phase intersection.
For every phase present in BOTH self AND other, invoke
f(self_value, other_value) and collect the result keyed
by phase. Phases present in only one input are absent from
the result.
Intersection-only — NOT Iterator::zip semantics. This
pairs values by phase key, not by position; a missing phase
on either side surfaces as an absence in the result, never
as a synthesized zero or default. Callers that want to act
on coverage gaps compare the result map’s length against
either input’s length.
Both values are passed BY VALUE — the trait constrains
T: Copy and U: Copy to keep the closure body free of
*s / *c deref noise that would otherwise dominate every
composed-metric expression. Non-Copy element types are out
of scope; per-phase reducers in this crate already return
scalar Copy values (u64, f64, i64).
Sourcefn ratio_across_phases<'v>(
&self,
verdict: &'v mut Verdict,
label: impl Into<String>,
earlier: Phase,
later: Phase,
) -> CrossPhaseRatio<'v, T>
fn ratio_across_phases<'v>( &self, verdict: &'v mut Verdict, label: impl Into<String>, earlier: Phase, later: Phase, ) -> CrossPhaseRatio<'v, T>
Cross-phase ratio comparator on a pre-reduced per-phase
map. Mirrors SeriesField::ratio_across_phases’s
chain shape — .at_most(ceiling) records a failure detail
or pass info note via the supplied verdict — but operates
on the map directly so caller-derived per-phase values
(e.g. a fraction of two counter deltas) skip a synthetic-
SeriesField intermediate.
Three load-bearing differences from the SeriesField entry:
- No implicit label. SeriesField pulls its
.label()for the failure message; the map has no label, so the caller names the metric being compared at the call site. - Pre-reduced values. SeriesField reduces by
last-Ok-sample at each comparator call; this trait
operates on values already reduced by any compatible
upstream reducer (
SeriesField::counter_delta_per_phase,SeriesField::last_per_phase, or a caller-defined fold). T: Copy— the map’s per-phase value is copied out into theCrossPhaseRatiocarrier’sOption<T>fields. MatchesSeriesField::value_at_phase’s bound for the same reason.
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.