Struct dyer::component::request::Request [−][src]
pub struct Request {
pub inner: InnerRequest,
pub body: Body,
pub metar: MetaRequest,
}
Expand description
An Wrapper of http::Request
An HTTP request consists of a head and a potentially optional body. The body component is
generic, enabling arbitrary types to represent the HTTP body. For example, the body could be
VecAffix
and Task
roughly add up to a Request
,
Fields
inner: InnerRequest
body: Body
metar: MetaRequest
Implementations
Create an instance of RequestBuilder
that used to build a Request
Examples
let request = Request::default();
.body(());
get shared reference to body of RequestBuilder
Examples
let request = Request::default();
assert!(request.body().is_none());
get mutable reference to body of RequestBuilder
Examples
let request = Request::default();
request.body_mut() = 3;
assert!(request.body_mut().is_none());
get shared reference to extensions of RequestBuilder
Examples
struct S {}
let request = Request::default();
.body(());
let s = S {};
request.extensions_mut.insert(s);
assert_eq!(request.extensions().get::<S>(), &s);
get mutable reference to extensions of RequestBuilder
Examples
let request = Request::default();
.body(());
request.extensions_mut().insert(vec![1,2,3]);
assert_eq!(request.extensions().get::<Vec<_>>(), &vec![1,2,3]);
get shared reference to exts of RequestBuilder
Examples
struct S {}
let request = Request::default();
.body(());
let s = S {};
request.exts_mut.insert(s);
assert_eq!(request.exts().get::<S>(), &s);
get mutable reference to exts of RequestBuilder
Examples
let request = Request::default();
.body(());
request.exts_mut().insert(vec![1,2,3]);
assert_eq!(request.exts().get::<Vec<_>>(), &vec![1,2,3]);
get shared reference to body_fn of Task
Examples
let reqeust = Request::default();
.body_fn(body_fn)
.body(());
assert_eq!(*reqeust.body_fn(), body_fn);
set the body_fn of Request
,
Examples
let task = Request::default();
.as_mut()
.body_fn_mut(body_fn);
assert_eq!(*Request.body_fn(), body_fn);
get shared reference to info of Request
Examples
let request = request::default();
assert_eq!(request.info().used, 0);
get mutable reference to info of Task
Examples
let request = request::default();
task.info_mut().unique = false;
assert_eq!(*task.info_ref().unique, false);
Consume the request and obtain the body
Examples
let request = request::default();
assert!(request.into_body().is_empty());
Convert the body of the request
with function
Examples
let request = request::default();
let new= request.map(|v| v + 1 );
assert_eq!(new.body, vec![2,3,4]);
Create new Request
directly with body, inner data
Examples
let request = request::default();
let ( mut inner, body, meta ) = request.into_parts();
let _ = request::from_parts(inner, body, meta);
split request
into body, inner data
Examples
let request = request::default();
let (_inner, _body, _meta ) = request.into_parts();
Create new Request
directly with Task and Affix(Optional)
Examples
let request = request::default();
let ( mut inner, body, meta ) = request.into_parts();
let _ = request::from_parts(inner, body, meta);
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
transform a Request
into hyper::Request
Auto Trait Implementations
impl !RefUnwindSafe for Request
impl !UnwindSafe for Request
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more