pub trait Middleware: Send + Sync {
// Provided methods
fn before<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_error: &'life2 Box<dyn Error + Send + Sync>,
_ctx: &'life3 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}
Expand description
Gentle enhancer—optional hooks with forgiving defaults. Trait that middleware implementations can implement. Implementors can override any combination of before(), after(), and on_error().
Provided Methods§
Sourcefn before<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
With selfless optionality, do nothing by default.
Sourcefn after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Forgiving default.
Sourcefn on_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_error: &'life2 Box<dyn Error + Send + Sync>,
_ctx: &'life3 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn on_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_link: Option<&'life1 dyn LegacyLink>,
_error: &'life2 Box<dyn Error + Send + Sync>,
_ctx: &'life3 Context,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Compassionate error handling.