pub trait Middleware: Send + Sync {
// Required method
fn name(&self) -> String;
// Provided methods
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§
Provided Methods§
Sourcefn 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 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,
在事务到达核心分发之前处理事务
Sourcefn 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,
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