pub struct Phase(/* private fields */);Expand description
Identifier for a scenario phase. Newtype over u16 carrying
the same 1-indexed encoding documented on every other
phase-touching site: Phase::BASELINE is the pre-first-Step
settle window (u16 0); Phase::step(k) is scenario Step k
at 1-indexed u16 k + 1. The newtype catches the bug class
where a raw u16 flows between sites that disagree about
0-indexed vs 1-indexed Step encoding, and gives operators
readable construction at consumer sites (Phase::BASELINE /
Phase::step(2) instead of magic 0u16 / 3u16).
Wire-format identical to a u16 via #[serde(transparent)] —
the on-disk sidecar shape is unchanged from the bare-u16
pipeline, and existing JSON / typeshare consumers see the same
scalar field. .phase_raw() exposes the inner u16 for paths
that hand the value to a serializer or formatter that does not
understand the newtype.
Implementations§
Source§impl Phase
impl Phase
Sourcepub const BASELINE: Self
pub const BASELINE: Self
Pre-first-Step settle window. The framework writes
Phase::BASELINE to Ctx::current_step at scenario start
(before any Step’s current_step.store advance), so any
capture taken before the first Step transition stamps with
this value.
Sourcepub const fn step(zero_indexed: u16) -> Self
pub const fn step(zero_indexed: u16) -> Self
Construct a Phase for the zero_indexed-th scenario Step.
The 1-indexed encoding (Step 0 → u16 1, Step 1 → u16 2,
…) keeps BASELINE unambiguous at u16 0. Saturates at
u16::MAX rather than overflowing — a scenario with > 65k
Steps is pathological and the saturating value still
distinguishes “well past any real Step” from BASELINE.
Sourcepub const fn is_baseline(&self) -> bool
pub const fn is_baseline(&self) -> bool
True iff this is Phase::BASELINE (the pre-first-Step
settle window).
Sourcepub const fn as_u16(self) -> u16
pub const fn as_u16(self) -> u16
Inner u16. Use this when handing the value to a
serializer / formatter / external consumer that does not
understand the newtype. Production callers that build a
Phase for downstream comparison should prefer
Phase::BASELINE / Phase::step(k) over wrapping a raw
u16 themselves.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Phase
impl<'de> Deserialize<'de> for Phase
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for Phase
impl Display for Phase
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
"BASELINE" for Phase::BASELINE, "Step[k]" for
Phase::step (decoded back via the 1-indexed
encoding). Matches the labels PhaseBucket embeds in
label so operators see consistent phase identifiers
across structured-sidecar reads and ad-hoc format!
output.
Source§impl From<u16> for Phase
impl From<u16> for Phase
Source§fn from(value: u16) -> Self
fn from(value: u16) -> Self
Wrap a raw 1-indexed encoded value as a Phase. Production
paths that already have the encoded value (e.g. drained from
the host-side mirror of current_step, or read out of a
deserialized sidecar) construct the typed wrapper via this
conversion without re-deriving the encoding.
Source§impl Ord for Phase
impl Ord for Phase
Source§impl PartialOrd for Phase
impl PartialOrd for Phase
impl Copy for Phase
impl Eq for Phase
impl StructuralPartialEq for Phase
Auto Trait Implementations§
impl Freeze for Phase
impl RefUnwindSafe for Phase
impl Send for Phase
impl Sync for Phase
impl Unpin for Phase
impl UnwindSafe for Phase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more