Skip to main content

ActorFailure

Enum ActorFailure 

Source
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 OnStart lacks an actor instance (the actor was never constructed).
  • Only OnIdleThenOnStop carries a second error (the on_stop cleanup failure after the primary on_idle failure).

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.

Fields

§error: T::Error

The error returned by on_start.

§

OnIdle

on_idle returned an error and the subsequent on_stop cleanup succeeded.

Fields

§actor: T

The actor instance, recovered for inspection or restart.

§error: T::Error

The error returned by on_idle.

§

OnStop

on_stop returned an error during shutdown.

Fields

§actor: T

The actor instance, recovered for inspection or restart.

§error: T::Error

The error returned by on_stop.

§

OnIdleThenOnStop

on_idle returned an error, and then on_stop also failed while cleaning up.

Fields

§actor: T

The actor instance, recovered for inspection or restart.

§error: T::Error

The primary error returned by on_idle.

§stop_error: T::Error

The secondary error returned by on_stop during cleanup.

Implementations§

Source§

impl<T: Actor> ActorFailure<T>

Source

pub fn phase(&self) -> FailurePhase

Returns the lifecycle phase this failure occurred in.

Source

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.

Source

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).

Source

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.

Source

pub fn into_actor(self) -> Option<T>

Consumes the failure and returns the recovered actor instance, if any.

Source

pub fn stop_error(&self) -> Option<&T::Error>

Returns the on_stop cleanup error, present only for OnIdleThenOnStop.

Source

pub fn into_stop_error(self) -> Option<T::Error>

Consumes the failure and returns the on_stop cleanup error, present only for OnIdleThenOnStop.

Trait Implementations§

Source§

impl<T: Debug + Actor> Debug for ActorFailure<T>
where T::Error: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ActorFailure<T>
where <T as Actor>::Error: Freeze, T: Freeze,

§

impl<T> RefUnwindSafe for ActorFailure<T>

§

impl<T> Send for ActorFailure<T>

§

impl<T> Sync for ActorFailure<T>
where <T as Actor>::Error: Sync, T: Sync,

§

impl<T> Unpin for ActorFailure<T>
where <T as Actor>::Error: Unpin, T: Unpin,

§

impl<T> UnsafeUnpin for ActorFailure<T>
where <T as Actor>::Error: UnsafeUnpin, T: UnsafeUnpin,

§

impl<T> UnwindSafe for ActorFailure<T>
where <T as Actor>::Error: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more