Struct Body

Source
pub struct Body { /* private fields */ }

Implementations§

Source§

impl Body

Source

pub fn new() -> Body

Creates a new empty Body.

Source

pub fn from_bytes(bytes: impl Into<Bytes>) -> Body

Creates a new Body from the given bytes.

Source

pub fn copy_from_slice(slice: impl AsRef<[u8]>) -> Body

Creates a new Body from the given bytes.

Source

pub fn from_hyper(body: Incoming) -> Body

Creates a new Body from a hyper::body::Incoming.

Source

pub fn from_sync_reader<R>(reader: R) -> Body
where R: Read + Send + Sync + 'static,

Creates a new Body from a Read implementation.

Source

pub fn from_async_reader<R>(reader: R) -> Body
where R: AsyncRead + Send + Sync + 'static,

Creates a new Body from an AsyncRead implementation.

Source

pub fn from_async_bytes_streamer<S>(streamer: S) -> Body
where S: Stream<Item = Result<Bytes, Error>> + Send + Sync + 'static,

Creates a new Body from a Stream<Item=io::Result<Bytes>> implementation.

Source

pub fn serialize<S>(value: &S) -> Result<Body, Error>
where S: Serialize + ?Sized,

Creates a new Body from a serializeable object.

Source

pub fn is_empty(&self) -> bool

Returns true if we know the body is empty, the body still might be empty but we just don’t know it yet

Source

pub fn len(&self) -> Option<usize>

Returns a length if it is already known.

Source

pub fn set_size_limit(&mut self, size: Option<usize>)

Sets a read size limit.

Source

pub fn set_timeout(&mut self, timeout: Option<Duration>)

Sets a read timeout, the timer starts counting after you call into_*

Source

pub fn take(&mut self) -> Body

Takes the body and replaces it with an empty one.

Source

pub async fn into_bytes(self) -> Result<Bytes, Error>

Converts the Body into Bytes.

Source

pub async fn into_string(self) -> Result<String, Error>

Converts the Body into a string.

Source

pub fn into_sync_reader(self) -> BodySyncReader

Converts the Body into a type that implements Read.

Source

pub fn into_async_reader(self) -> BodyAsyncReader

Converts the Body into a type that implements AsyncRead.

Source

pub fn into_async_bytes_streamer(self) -> BodyAsyncBytesStreamer

Converts the Body into a type that implements Stream<Item=io::Result<Bytes>>.

Source

pub fn into_http_body(self) -> BodyHttp

Converts the Body into a type that implements hyper::body::Body.

Source

pub async fn deserialize<D>(self) -> Result<D, Error>
where D: DeserializeOwned + Send + 'static,

Converts the Body into a deserializeable type.

Trait Implementations§

Source§

impl Debug for Body

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Body

Source§

fn default() -> Body

Returns the “default value” for a type. Read more
Source§

impl From<&'static str> for Body

Source§

fn from(s: &'static str) -> Body

Converts to this type from the input type.
Source§

impl From<Body> for Response

Source§

fn from(body: Body) -> Response

Converts to this type from the input type.
Source§

impl From<Bytes> for Body

Source§

fn from(b: Bytes) -> Body

Converts to this type from the input type.
Source§

impl From<HyperBody> for Body

Source§

fn from(hyper_body: HyperBody) -> Self

Converts to this type from the input type.
Source§

impl From<Incoming> for Body

Source§

fn from(i: Incoming) -> Body

Converts to this type from the input type.
Source§

impl From<String> for Body

Source§

fn from(s: String) -> Body

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Body

Source§

fn from(b: Vec<u8>) -> Body

Converts to this type from the input type.
Source§

impl IntoResponse for Body

Auto Trait Implementations§

§

impl !Freeze for Body

§

impl !RefUnwindSafe for Body

§

impl Send for Body

§

impl Sync for Body

§

impl Unpin for Body

§

impl !UnwindSafe for Body

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<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<R> IntoRouteResult for R
where R: IntoResponse,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,