Skip to main content

Module phase

Module phase 

Source
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§

EarlyDone
super::Phase::Early has run; super::ValidationSession::run_late is the only legal next step.
LateDone
Both phases have run; super::ValidationSession::finalize is the only legal next step.
Pending
Neither phase has run yet; the session was just constructed by super::ValidationSession::new.

Traits§

SessionPhase
Marker trait for super::ValidationSession phase markers. Sealed: only the markers in this module implement it.