pub struct Request {
pub header: RequestHeader,
pub body: Body,
}Expand description
The request that is received from a client.
Fields
header: RequestHeaderbody: BodyImplementations
sourceimpl Request
impl Request
sourcepub fn new(header: RequestHeader, body: Body) -> Request
pub fn new(header: RequestHeader, body: Body) -> Request
Creates a new Request.
sourcepub fn header(&self) -> &RequestHeader
pub fn header(&self) -> &RequestHeader
Get the request header by reference.
sourcepub fn set_size_limit(&mut self, size: Option<usize>)
pub fn set_size_limit(&mut self, size: Option<usize>)
Sets a read size limit.
sourcepub fn set_timeout(&mut self, timeout: Option<Duration>)
pub fn set_timeout(&mut self, timeout: Option<Duration>)
Sets a read timeout, the timer starts counting after you call into_*
sourcepub async fn deserialize<D>(
&mut self
) -> impl Future<Output = Result<D, DeserializeError>>where
D: 'static + DeserializeOwned + Send,
pub async fn deserialize<D>(
&mut self
) -> impl Future<Output = Result<D, DeserializeError>>where
D: 'static + DeserializeOwned + Send,
Tries to deserialize the request body.
Errors
- If the header
content-typedoes not containapplication/json. - If the body does not contain a valid json or some data is missing.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl !UnwindSafe for Request
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more