[][src]Trait openapi_context::context::Push

pub trait Push<T> {
    type Result;
    fn push(self, v: 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::service::Service for MiddlewareService<T, C>
    where
        C: Push<MyItem1, Result=D> + Send + 'static,
        D: Push<MyItem2, Result=E>,
        E: Push<MyItem3>,
        E::Result: Send + 'static,
        T: hyper::service::Service<ReqBody=ContextualPayload<hyper::Body, E::Result>>
{
    type ReqBody = ContextualPayload<hyper::Body, C>;
    type ResBody = T::ResBody;
    type Error = T::Error;
    type Future = T::Future;
    fn call(&mut self, req : hyper::Request<Self::ReqBody>) -> Self::Future {
        let (head, body) = req.into_parts();
        let context = body.context
            .push(MyItem1{})
            .push(MyItem2{})
            .push(MyItem3{});
        let req = hyper::Request::from_parts(head, ContextualPayload { inner: body.inner, context });
        self.inner.call(req)
    }
}

Associated Types

type Result

The type that results from adding an item.

Loading content...

Required methods

fn push(self, v: T) -> Self::Result

Inserts a value.

Loading content...

Implementors

impl Push<Option<AuthData>> for EmptyContext[src]

type Result = ContextBuilder<Option<AuthData>, Self>

impl Push<Option<Authorization>> for EmptyContext[src]

impl Push<XSpanId> for EmptyContext[src]

type Result = ContextBuilder<XSpanId, Self>

impl<C, T> Push<Option<AuthData>> for ContextBuilder<T, C>[src]

type Result = ContextBuilder<Option<AuthData>, Self>

impl<C, T> Push<Option<Authorization>> for ContextBuilder<T, C>[src]

impl<C, T> Push<XSpanId> for ContextBuilder<T, C>[src]

type Result = ContextBuilder<XSpanId, Self>

Loading content...