[][src]Struct hyper::body::Body

#[must_use = "streams do nothing unless polled"]
pub struct Body { /* fields omitted */ }

A stream of Chunks, used when receiving bodies.

A good default Payload to use in many applications.

Also implements futures::Stream, so stream combinators may be used.

Methods

impl Body[src]

pub fn empty() -> Body[src]

Create an empty Body stream.

Example

use hyper::{Body, Request};

// create a `GET /` request
let get = Request::new(Body::empty());

pub fn channel() -> (Sender, Body)[src]

Create a Body stream with an associated sender half.

Useful when wanting to stream chunks from another thread.

pub fn wrap_stream<S>(stream: S) -> Body where
    S: Stream + Send + 'static,
    S::Error: Into<Box<dyn StdError + Send + Sync>>,
    Chunk: From<S::Item>, 
[src]

Wrap a futures Stream in a box inside Body.

Example

let chunks = vec![
    "hello",
    " ",
    "world",
];

let stream = futures::stream::iter_ok::<_, ::std::io::Error>(chunks);

let body = Body::wrap_stream(stream);

pub fn on_upgrade(self) -> OnUpgrade[src]

Converts this Body into a Future of a pending HTTP upgrade.

See the upgrade module for more.

Trait Implementations

impl Payload for Body[src]

type Data = Chunk

A buffer of bytes representing a single chunk of a body.

type Error = Error

The error type of this stream.

impl Default for Body[src]

impl From<Chunk> for Body[src]

impl From<Box<dyn Stream<Item = Chunk, Error = Box<dyn Error + 'static + Sync + Send>> + 'static + Send>> for Body[src]

impl From<Bytes> for Body[src]

impl From<Vec<u8>> for Body[src]

impl From<&'static [u8]> for Body[src]

impl From<Cow<'static, [u8]>> for Body[src]

impl From<String> for Body[src]

impl From<&'static str> for Body[src]

impl From<Cow<'static, str>> for Body[src]

impl Debug for Body[src]

impl Stream for Body[src]

type Item = Chunk

The type of item this stream will yield on success.

type Error = Error

The type of error this stream may generate.

impl Body for Body[src]

type Data = Chunk

Values yielded by the Body.

type Error = Error

The error type this BufStream might generate.

Auto Trait Implementations

impl Send for Body

impl Unpin for Body

impl !Sync for Body

impl !UnwindSafe for Body

impl !RefUnwindSafe for Body

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Body for T where
    T: BufStream
[src]

type Data = <T as BufStream>::Item

Values yielded by the Body.

type Error = <T as BufStream>::Error

The error type this BufStream might generate.

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]