a3s_boot/pipeline/
interceptor.rs1use super::ExecutionContext;
2use crate::{BootResponse, BoxFuture, Result};
3
4pub trait Interceptor: Send + Sync + 'static {
6 fn before(&self, _context: ExecutionContext) -> BoxFuture<'static, Result<()>> {
7 Box::pin(async { Ok(()) })
8 }
9
10 fn after(
11 &self,
12 _context: ExecutionContext,
13 response: BootResponse,
14 ) -> BoxFuture<'static, Result<BootResponse>> {
15 Box::pin(async move { Ok(response) })
16 }
17}
18
19impl<F, Fut> Interceptor for F
20where
21 F: Fn(ExecutionContext) -> Fut + Send + Sync + 'static,
22 Fut: std::future::Future<Output = Result<()>> + Send + 'static,
23{
24 fn before(&self, context: ExecutionContext) -> BoxFuture<'static, Result<()>> {
25 Box::pin(self(context))
26 }
27}