pub struct Request {
pub header: RequestHeader,
pub body: Body,
}
Expand description
The request that is received from a client.
Fields§
§header: RequestHeader
§body: Body
Implementations§
source§impl 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: DeserializeOwned + Send + 'static,
pub async fn deserialize<D>( &mut self ) -> impl Future<Output = Result<D, DeserializeError>>where D: DeserializeOwned + Send + 'static,
Tries to deserialize the request body.
Errors
- If the header
content-type
does not containapplication/json
. - If the body does not contain a valid json or some data is missing.