pub enum ActorFailure<T: Actor> {
OnStart {
error: T::Error,
},
OnIdle {
actor: T,
error: T::Error,
},
OnStop {
actor: T,
error: T::Error,
},
OnIdleThenOnStop {
actor: T,
error: T::Error,
stop_error: T::Error,
},
}Expand description
Phase-specific payload of a failed actor lifecycle.
Each variant carries exactly the data that can exist in that phase, so the invariants that were previously documentation-only are enforced by the type system:
- Only
OnStartlacks an actor instance (the actor was never constructed). - Only
OnIdleThenOnStopcarries a second error (theon_stopcleanup failure after the primaryon_idlefailure).
Use the accessors (phase, error,
actor, stop_error) for uniform access
across variants, or match directly when handling a specific phase.
Variants§
OnStart
on_start returned an error; the actor was
never constructed, so no instance is available.
OnIdle
on_idle returned an error and the subsequent
on_stop cleanup succeeded.
Fields
actor: TThe actor instance, recovered for inspection or restart.
OnStop
on_stop returned an error during shutdown.
Fields
actor: TThe actor instance, recovered for inspection or restart.
OnIdleThenOnStop
Implementations§
Source§impl<T: Actor> ActorFailure<T>
impl<T: Actor> ActorFailure<T>
Sourcepub fn phase(&self) -> FailurePhase
pub fn phase(&self) -> FailurePhase
Returns the lifecycle phase this failure occurred in.
Sourcepub fn error(&self) -> &T::Error
pub fn error(&self) -> &T::Error
Returns the primary error of this failure.
For OnIdleThenOnStop this is the original
on_idle error; the on_stop cleanup error is available via
stop_error.
Sourcepub fn into_error(self) -> T::Error
pub fn into_error(self) -> T::Error
Consumes the failure and returns the primary error.
Drops the recovered actor instance (if any) and the on_stop cleanup
error (for OnIdleThenOnStop).
Sourcepub fn actor(&self) -> Option<&T>
pub fn actor(&self) -> Option<&T>
Returns the recovered actor instance, if one exists.
None only for OnStart failures, where the actor was
never constructed.
Sourcepub fn into_actor(self) -> Option<T>
pub fn into_actor(self) -> Option<T>
Consumes the failure and returns the recovered actor instance, if any.
Sourcepub fn stop_error(&self) -> Option<&T::Error>
pub fn stop_error(&self) -> Option<&T::Error>
Returns the on_stop cleanup error, present only for
OnIdleThenOnStop.
Sourcepub fn into_stop_error(self) -> Option<T::Error>
pub fn into_stop_error(self) -> Option<T::Error>
Consumes the failure and returns the on_stop cleanup error, present
only for OnIdleThenOnStop.