Trait swagger::context::Push
[−]
[src]
pub trait Push<T> { type Result; fn push(self, _: T) -> Self::Result; }
Defines a method for inserting a value, changing the resulting type. Used to specify that a hyper service adds some data from the context, making it available to later layers, e.g.
struct MyItem1; struct MyItem2; struct MyItem3; struct MiddlewareService<T, C> { inner: T, marker: PhantomData<C>, } impl<T, C, D, E> hyper::server::Service for MiddlewareService<T, C> where C: Push<MyItem1, Result=D>, D: Push<MyItem2, Result=E>, E: Push<MyItem3>, T: hyper::server::Service<Request = (hyper::Request, E::Result)> { type Request = (hyper::Request, C); type Response = T::Response; type Error = T::Error; type Future = T::Future; fn call(&self, (req, context) : Self::Request) -> Self::Future { let context = context .push(MyItem1{}) .push(MyItem2{}) .push(MyItem3{}); self.inner.call((req, context)) } }
Associated Types
type Result
The type that results from adding an item.
Required Methods
Implementors
impl<U> Push<U> for EmptyContext type Result = ContextBuilder<U, Self>;
impl<C, T, U> Push<U> for ContextBuilder<T, C> type Result = ContextBuilder<U, Self>;