Trait swagger::context::Has [] [src]

pub trait Has<T> {
    fn get(&self) -> &T;
fn get_mut(&mut self) -> &mut T;
fn set(&mut self, value: T); }

Defines methods for accessing, modifying, adding and removing the data stored in a context. Used to specify the requirements that a hyper service makes on a generic context type that it receives with a request, e.g.

struct MyService<C> {
    marker: PhantomData<C>,
}

impl<C> hyper::server::Service for MyService<C>
    where C: Has<MyItem>,
{
    type Request = (hyper::Request, C);
    type Response = hyper::Response;
    type Error = hyper::Error;
    type Future = Box<Future<Item=Self::Response, Error=Self::Error>>;
    fn call(&self, (req, context) : Self::Request) -> Self::Future {
        do_something_with_my_item(Has::<MyItem>::get(&context));
        Box::new(ok(hyper::Response::new()))
    }
}

Required Methods

Important traits for &'a mut W

Get an immutable reference to the value.

Important traits for &'a mut W

Get a mutable reference to the value.

Set the value.

Implementors