1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use crate::Middleware; use std::sync::Arc; pub(crate) type MiddlewareItem = Box<dyn Middleware + Send + Sync + 'static>; pub struct Pipe<'a> { pub(crate) name: &'a str, pub(crate) middlewares: Vec<Arc<MiddlewareItem>>, } impl<'a> Pipe<'a> { pub fn new(name: &'a str) -> Self { Self { name, middlewares: vec![], } } #[allow(clippy::should_implement_trait)] pub fn add<M>(mut self, middleware: M) -> Self where M: Middleware + Send + Sync + 'static, { self.middlewares.push(Arc::new(Box::new(middleware))); self } }