Expand description
Phantom-typed phase markers for ValidationSession.
These markers track the session’s lifecycle position at the type
level. The phase transitions ValidationSession::run_early,
ValidationSession::run_late, and ValidationSession::finalize
consume the session by value and produce one bound to the next
marker. A caller cannot call run_late before run_early, cannot
call either phase twice, and cannot call finalize before run_late
because the relevant method does not exist on the wrong-phase type.
Pre-#1236 the same invariant was enforced at runtime via a bitmask
on ValidationSession (debug_assert! in debug builds, silent
no-op in release). Compile-time enforcement closes the release-mode
gap and makes the contract self-documenting at call sites.
Known follow-up scope (see issue #1236): the typestate guards the
session lifecycle, but the directive list itself is still a plain
&[Directive] / &[Spanned<Directive>]. A caller can still pass
pre-booking directives to ValidationSession::<EarlyDone>::run_late
without a compile-time error. That gap requires phase markers on
the directive collection (mirroring rustledger-loader’s
Directives<Phase>), which would cross the validate/loader crate
boundary; deferred to a follow-up PR.
Structs§
- Early
Done super::Phase::Earlyhas run;super::ValidationSession::run_lateis the only legal next step.- Late
Done - Both phases have run;
super::ValidationSession::finalizeis the only legal next step. - Pending
- Neither phase has run yet; the session was just constructed by
super::ValidationSession::new.
Traits§
- Session
Phase - Marker trait for
super::ValidationSessionphase markers. Sealed: only the markers in this module implement it.