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) -> Result<D, DeserializeError>where
D: DeserializeOwned + Send + 'static,
pub async fn deserialize<D>(&mut self) -> 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.
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more