Skip to main content

Request

Struct Request 

Source
pub struct Request { /* private fields */ }
Expand description

A canonical, transport-independent HTTP request.

Combines the immutable request head, the bounded request body, and connection metadata into a single value. The runtime constructs Request instances from incoming connections; services receive them by value.

§Hyper independence

No Hyper type appears in this struct or its public API. The body stream is opaque behind RequestBody.

§One-shot body

The body can only be consumed once, either via read_all or by streaming chunks. After consumption, the body is in the Complete state.

Implementations§

Source§

impl Request

Source

pub fn new( head: RequestHead, body: RequestBody, connection: ConnectionInfo, ) -> Self

Create a new request envelope.

Prefer using the runtime adapter (Hyper → canonical conversion) for production use. This constructor is for tests and downstream code that already has validated components.

Source

pub fn head(&self) -> &RequestHead

Returns the immutable request head.

Source

pub fn body(&self) -> &RequestBody

Returns a reference to the request body.

Source

pub fn into_parts(self) -> (RequestHead, RequestBody, ConnectionInfo)

Consume the request, returning the head and body separately.

This is useful for services that need to pass the head to one code path and the body to another.

Source

pub fn into_body(self) -> RequestBody

Consume the request, returning the body.

The request head and connection info are discarded.

Source

pub fn connection(&self) -> &ConnectionInfo

Returns a reference to the connection metadata.

Source

pub fn into_head_and_body(self) -> (RequestHead, RequestBody)

Deconstruct the request into head and a body-bearing tuple.

Returns (head, body).

Trait Implementations§

Source§

impl Debug for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.