Skip to main content

Lifecycle

Trait Lifecycle 

Source
pub trait Lifecycle {
    type Key: Hash + Eq + Clone + Serialize + DeserializeOwned;
    type State;
    type Context;
    type Output;
    type Error;

    // Required methods
    fn key(&self) -> Self::Key;
    fn enter(
        self,
        ctx: &mut Self::Context,
        output: &mut Self::Output,
    ) -> Result<Self::State, Self::Error>;
    fn reconcile_self(
        self,
        state: &mut Self::State,
        ctx: &mut Self::Context,
        output: &mut Self::Output,
    ) -> Result<(), Self::Error>;
    fn exit(
        state: Self::State,
        ctx: &mut Self::Context,
        output: &mut Self::Output,
    ) -> Result<(), Self::Error>;

    // Provided methods
    fn display_name(&self) -> String { ... }
    fn enhance_lifecycle_context(&self, _ctx: &mut LifecycleContext) { ... }
    fn enhance_lifecycle_state_context(
        _state: &Self::State,
        _ctx: &mut LifecycleContext,
    ) { ... }
    fn lifecycle_context(&self) -> LifecycleContext { ... }
    fn lifecycle_state_context(state: &Self::State) -> LifecycleContext { ... }
    fn wrap_enter(
        self,
        ctx: &mut Self::Context,
        output: &mut Self::Output,
    ) -> Result<Self::State, Self::Error>
       where Self: Sized { ... }
    fn wrap_reconcile(
        self,
        state: &mut Self::State,
        ctx: &mut Self::Context,
        output: &mut Self::Output,
    ) -> Result<(), Self::Error>
       where Self: Sized { ... }
    fn wrap_exit(
        state: Self::State,
        ctx: &mut Self::Context,
        output: &mut Self::Output,
    ) -> Result<(), Self::Error> { ... }
}

Required Associated Types§

Required Methods§

Source

fn key(&self) -> Self::Key

Source

fn enter( self, ctx: &mut Self::Context, output: &mut Self::Output, ) -> Result<Self::State, Self::Error>

Source

fn reconcile_self( self, state: &mut Self::State, ctx: &mut Self::Context, output: &mut Self::Output, ) -> Result<(), Self::Error>

Source

fn exit( state: Self::State, ctx: &mut Self::Context, output: &mut Self::Output, ) -> Result<(), Self::Error>

Provided Methods§

Source

fn display_name(&self) -> String

Human-readable label for logs and traces. Defaults to empty; override when you want lifecycle events to identify themselves by something other than key.

Source

fn enhance_lifecycle_context(&self, _ctx: &mut LifecycleContext)

Source

fn enhance_lifecycle_state_context( _state: &Self::State, _ctx: &mut LifecycleContext, )

Source

fn lifecycle_context(&self) -> LifecycleContext

Source

fn lifecycle_state_context(state: &Self::State) -> LifecycleContext

Source

fn wrap_enter( self, ctx: &mut Self::Context, output: &mut Self::Output, ) -> Result<Self::State, Self::Error>
where Self: Sized,

Source

fn wrap_reconcile( self, state: &mut Self::State, ctx: &mut Self::Context, output: &mut Self::Output, ) -> Result<(), Self::Error>
where Self: Sized,

Source

fn wrap_exit( state: Self::State, ctx: &mut Self::Context, output: &mut Self::Output, ) -> Result<(), Self::Error>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§