Struct axum::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>) -> RequestParts<B>
pub fn new(req: Request<B>) -> RequestParts<B>
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
HeaderMap
has been extracted, that istake_headers
have been called. - The full
Extensions
has been extracted, that istake_extensions
have been called. - The request body has been extracted, that is
take_body
have 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<HeaderValue>>
pub fn headers(&self) -> Option<&HeaderMap<HeaderValue>>
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<HeaderValue>>
pub fn headers_mut(&mut self) -> Option<&mut HeaderMap<HeaderValue>>
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<HeaderValue>>
pub fn take_headers(&mut self) -> Option<HeaderMap<HeaderValue>>
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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> PolicyExt for T where
T: ?Sized,
impl<T> PolicyExt for T where
T: ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more