Trait Middleware

Source
pub trait Middleware: Send + Sync {
    // Required methods
    fn name(&self) -> String;
    fn before_dispatch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        transaction: &'life1 mut Transaction,
    ) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn after_dispatch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        state: Option<Arc<State>>,
        transactions: &'life1 [Transaction],
    ) -> Pin<Box<dyn Future<Output = ForgeResult<Option<Transaction>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

可以用于事务处理的中间件 trait

Required Methods§

Source

fn name(&self) -> String

返回中间件的名称

Source

fn before_dispatch<'life0, 'life1, 'async_trait>( &'life0 self, transaction: &'life1 mut Transaction, ) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

在事务到达核心分发之前处理事务

Source

fn after_dispatch<'life0, 'life1, 'async_trait>( &'life0 self, state: Option<Arc<State>>, transactions: &'life1 [Transaction], ) -> Pin<Box<dyn Future<Output = ForgeResult<Option<Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

在核心分发之后处理结果 返回一个可能包含需要额外处理的事务的 MiddlewareResult

Implementors§