ResponseBody

Struct ResponseBody 

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

An asynchronous stream representing the body of HTTP response.

Implementations§

Source§

impl ResponseBody

Source

pub fn empty() -> ResponseBody

Create an instance of empty ResponseBody.

Source

pub fn once<T>(body: T) -> ResponseBody
where T: Into<Bytes>,

Create an instance of ResponseBody from a chunk of bytes.

Source

pub fn wrap_stream<T>(stream: T) -> ResponseBody
where T: Stream<Item = Bytes, Error = Error> + Send + 'static,

Create an instance of ResponseBody from a Stream of bytes.

Source

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

Return the length of bytes if available.

Source

pub fn poll_data(&mut self) -> PollResult<Option<Bytes>, Error>

Poll an element of chunk from this stream.

Trait Implementations§

Source§

impl Debug for ResponseBody

Source§

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

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

impl Default for ResponseBody

Source§

fn default() -> ResponseBody

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

impl From<&'static [u8]> for ResponseBody

Source§

fn from(body: &'static [u8]) -> ResponseBody

Converts to this type from the input type.
Source§

impl From<&'static str> for ResponseBody

Source§

fn from(body: &'static str) -> ResponseBody

Converts to this type from the input type.
Source§

impl From<()> for ResponseBody

Source§

fn from(_: ()) -> ResponseBody

Converts to this type from the input type.
Source§

impl From<Bytes> for ResponseBody

Source§

fn from(body: Bytes) -> ResponseBody

Converts to this type from the input type.
Source§

impl From<String> for ResponseBody

Source§

fn from(body: String) -> ResponseBody

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for ResponseBody

Source§

fn from(body: Vec<u8>) -> ResponseBody

Converts to this type from the input type.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.