Struct axum_core::extract::RequestParts  
source · [−]pub struct RequestParts<B> { /* private fields */ }Expand description
The type used with FromRequest to extract data from requests.
Has several convenience methods for getting owned parts of the request.
Implementations
sourceimpl<B> RequestParts<B>
 
impl<B> RequestParts<B>
sourcepub fn new(req: Request<B>) -> Self
 
pub fn new(req: Request<B>) -> Self
Create a new RequestParts.
You generally shouldn’t need to construct this type yourself, unless
using extractors outside of axum for example to implement a
tower::Service.
sourcepub fn try_into_request(self) -> Result<Request<B>, Error>
 
pub fn try_into_request(self) -> Result<Request<B>, Error>
Convert this RequestParts back into a Request.
Fails if
- The full HeaderMaphas been extracted, that istake_headershave been called.
- The full Extensionshas been extracted, that istake_extensionshave been called.
- The request body has been extracted, that is take_bodyhave been called.
sourcepub fn method_mut(&mut self) -> &mut Method
 
pub fn method_mut(&mut self) -> &mut Method
Gets a mutable reference to the request method.
sourcepub fn version_mut(&mut self) -> &mut Version
 
pub fn version_mut(&mut self) -> &mut Version
Gets a mutable reference to the request HTTP version.
sourcepub fn headers(&self) -> Option<&HeaderMap>
 
pub fn headers(&self) -> Option<&HeaderMap>
Gets a reference to the request headers.
Returns None if the headers has been taken by another extractor.
sourcepub fn headers_mut(&mut self) -> Option<&mut HeaderMap>
 
pub fn headers_mut(&mut self) -> Option<&mut HeaderMap>
Gets a mutable reference to the request headers.
Returns None if the headers has been taken by another extractor.
sourcepub fn take_headers(&mut self) -> Option<HeaderMap>
 
pub fn take_headers(&mut self) -> Option<HeaderMap>
Takes the headers out of the request, leaving a None in its place.
sourcepub fn extensions(&self) -> Option<&Extensions>
 
pub fn extensions(&self) -> Option<&Extensions>
Gets a reference to the request extensions.
Returns None if the extensions has been taken by another extractor.
sourcepub fn extensions_mut(&mut self) -> Option<&mut Extensions>
 
pub fn extensions_mut(&mut self) -> Option<&mut Extensions>
Gets a mutable reference to the request extensions.
Returns None if the extensions has been taken by another extractor.
sourcepub fn take_extensions(&mut self) -> Option<Extensions>
 
pub fn take_extensions(&mut self) -> Option<Extensions>
Takes the extensions out of the request, leaving a None in its place.
sourcepub fn body(&self) -> Option<&B>
 
pub fn body(&self) -> Option<&B>
Gets a reference to the request body.
Returns None if the body has been taken by another extractor.
Trait Implementations
Auto Trait Implementations
impl<B> !RefUnwindSafe for RequestParts<B>
impl<B> Send for RequestParts<B> where
    B: Send, 
impl<B> Sync for RequestParts<B> where
    B: Sync, 
impl<B> Unpin for RequestParts<B> where
    B: Unpin, 
impl<B> !UnwindSafe for RequestParts<B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
 
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more