Skip to main content

Body

Struct Body 

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

The body of an HTTP message.

Implementations§

Source§

impl Body

Source

pub fn empty() -> Self

Creates an empty body.

Source

pub fn from_bytes(bytes: impl Into<Vec<u8>>) -> Self

Creates a body from bytes.

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Returns the body as bytes.

Source

pub fn len(&self) -> usize

Returns the body length in bytes.

Source

pub fn is_empty(&self) -> bool

Returns whether the body is empty.

Source

pub fn into_bytes(self) -> Vec<u8> ⓘ

Consumes the body and returns its bytes.

Trait Implementations§

Source§

impl Debug for Body

Source§

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

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

impl Default for Body

Source§

fn default() -> Self

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

impl From<&[u8]> for Body

Source§

fn from(bytes: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Body

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Body

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Body

Source§

fn from(bytes: Vec<u8>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Body

§

impl RefUnwindSafe for Body

§

impl Send for Body

§

impl Sync for Body

§

impl Unpin for Body

§

impl UnsafeUnpin 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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.