Skip to main content

TriggerHandler

Trait TriggerHandler 

Source
pub trait TriggerHandler<Ctx, Evt>: Send + Sync {
    // Required methods
    fn events(&self) -> Vec<Evt>;
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 Ctx,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn priority(&self) -> i32 { ... }
    fn continue_on_error(&self) -> bool { ... }
}
Expand description

Generic lifecycle trigger handler.

  • Ctx — entity-specific trigger context (e.g. TriggerContext<Order>)
  • Evt — trigger event type (e.g. TriggerEvent)

Required Methods§

Source

fn events(&self) -> Vec<Evt>

Events this handler responds to.

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 Ctx, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle the trigger event.

Provided Methods§

Source

fn priority(&self) -> i32

Execution priority — lower values run first. Default: 0.

Source

fn continue_on_error(&self) -> bool

Whether to keep dispatching after this handler errors. Default: false.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§