[−][src]Trait openapi_context::context::Has
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::service::Service for MyService<C> where C: Has<MyItem> + Send + 'static { type ReqBody = ContextualPayload<hyper::Body, C>; type ResBody = hyper::Body; type Error = std::io::Error; type Future = Box<dyn Future<Item=hyper::Response<Self::ResBody>, Error=Self::Error>>; fn call(&mut self, req : hyper::Request<Self::ReqBody>) -> Self::Future { let (head, body) = req.into_parts(); do_something_with_my_item(Has::<MyItem>::get(&body.context)); Box::new(ok(hyper::Response::new(hyper::Body::empty()))) } }
Required methods
fn get(&self) -> &T
Get an immutable reference to the value.
fn get_mut(&mut self) -> &mut T
Get a mutable reference to the value.
fn set(&mut self, value: T)
Set the value.