pub struct LifecycleStateMachine<State> { /* private fields */ }Expand description
Type-level lifecycle state machine
The State type parameter encodes the current lifecycle state, preventing
invalid transitions at compile time.
Poka-yoke: Invalid state transitions are impossible - the compiler prevents them.
Implementations§
Source§impl LifecycleStateMachine<Initial>
impl LifecycleStateMachine<Initial>
Sourcepub fn init(self) -> Result<LifecycleStateMachine<Initialized>>
pub fn init(self) -> Result<LifecycleStateMachine<Initialized>>
Transition from Initial to Initialized (run init phase)
Poka-yoke: Can only be called on Initial state - compiler enforces this.
Source§impl LifecycleStateMachine<Initialized>
impl LifecycleStateMachine<Initialized>
Sourcepub fn setup(self) -> Result<LifecycleStateMachine<Setup>>
pub fn setup(self) -> Result<LifecycleStateMachine<Setup>>
Transition from Initialized to Setup (run setup phase)
Poka-yoke: Can only be called on Initialized state - compiler enforces this.
Source§impl LifecycleStateMachine<Setup>
impl LifecycleStateMachine<Setup>
Sourcepub fn build(self) -> Result<LifecycleStateMachine<Built>>
pub fn build(self) -> Result<LifecycleStateMachine<Built>>
Transition from Setup to Built (run build phase)
Poka-yoke: Can only be called on Setup state - compiler enforces this.
Source§impl LifecycleStateMachine<Built>
impl LifecycleStateMachine<Built>
Sourcepub fn test(self) -> Result<LifecycleStateMachine<Tested>>
pub fn test(self) -> Result<LifecycleStateMachine<Tested>>
Transition from Built to Tested (run test phase)
Poka-yoke: Can only be called on Built state - compiler enforces this.
Source§impl LifecycleStateMachine<Tested>
impl LifecycleStateMachine<Tested>
Sourcepub fn deploy(self) -> Result<LifecycleStateMachine<Deployed>>
pub fn deploy(self) -> Result<LifecycleStateMachine<Deployed>>
Transition from Tested to Deployed (run deploy phase)
Poka-yoke: Can only be called on Tested state - compiler enforces this.
Source§impl<State> LifecycleStateMachine<State>
impl<State> LifecycleStateMachine<State>
Sourcepub fn state(&self) -> &LifecycleState
pub fn state(&self) -> &LifecycleState
Get the underlying lifecycle state
This allows accessing state information regardless of the current state marker.
Sourcepub fn state_mut(&mut self) -> &mut LifecycleState
pub fn state_mut(&mut self) -> &mut LifecycleState
Get mutable access to the underlying lifecycle state
Warning: Modifying state directly can break type-level invariants. Prefer using transition methods when possible.
Sourcepub fn has_completed_phase(&self, phase: &str) -> bool
pub fn has_completed_phase(&self, phase: &str) -> bool
Check if a phase has been completed
Sourcepub fn last_phase(&self) -> Option<&str>
pub fn last_phase(&self) -> Option<&str>
Get the last completed phase
Trait Implementations§
Source§impl<State: Clone> Clone for LifecycleStateMachine<State>
impl<State: Clone> Clone for LifecycleStateMachine<State>
Source§fn clone(&self) -> LifecycleStateMachine<State>
fn clone(&self) -> LifecycleStateMachine<State>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<State: Debug> Debug for LifecycleStateMachine<State>
impl<State: Debug> Debug for LifecycleStateMachine<State>
Auto Trait Implementations§
impl<State> Freeze for LifecycleStateMachine<State>where
PhantomData<State>: Freeze,
impl<State> RefUnwindSafe for LifecycleStateMachine<State>where
PhantomData<State>: RefUnwindSafe,
impl<State> Send for LifecycleStateMachine<State>where
PhantomData<State>: Send,
impl<State> Sync for LifecycleStateMachine<State>where
PhantomData<State>: Sync,
impl<State> Unpin for LifecycleStateMachine<State>where
PhantomData<State>: Unpin,
impl<State> UnsafeUnpin for LifecycleStateMachine<State>where
PhantomData<State>: UnsafeUnpin,
impl<State> UnwindSafe for LifecycleStateMachine<State>where
PhantomData<State>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EvidenceKind for T
impl<T> EvidenceKind for T
default fn kind_label(&self) -> &'static str
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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