Skip to main content

a3s_boot/pipeline/
pipe.rs

1use crate::{BootRequest, BoxFuture, Result};
2
3/// Transforms a request after guards and interceptor `before` hooks, before handlers run.
4pub trait Pipe: Send + Sync + 'static {
5    fn transform(&self, request: BootRequest) -> BoxFuture<'static, Result<BootRequest>>;
6}
7
8impl<F, Fut> Pipe for F
9where
10    F: Fn(BootRequest) -> Fut + Send + Sync + 'static,
11    Fut: std::future::Future<Output = Result<BootRequest>> + Send + 'static,
12{
13    fn transform(&self, request: BootRequest) -> BoxFuture<'static, Result<BootRequest>> {
14        Box::pin(self(request))
15    }
16}