[−][src]Struct hyper::Body
A stream of Chunk
s, 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 Error + Send + Sync>>,
Chunk: From<S::Item>,
[src][−]
S: Stream + Send + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>>,
Chunk: From<S::Item>,
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][+]
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][+]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src][−]
impl<T, U> Into for T where
U: From<T>,
[src][−]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src][−]
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src][−]
impl<T> Borrow for T where
T: ?Sized,
[src][−]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src][−]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src][−]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src][−]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src][−]
impl<T> Any for T where
T: 'static + ?Sized,
[src][−]
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src][−]
impl<T> StreamExt for T where
T: Stream + ?Sized,
[src][−]
T: Stream + ?Sized,
fn throttle(self, duration: Duration) -> Throttle<Self>
[src][−]
Throttle down the stream by enforcing a fixed delay between items. Read more
fn enumerate(self) -> Enumerate<Self>
[src][−]
Creates a new stream which gives the current iteration count as well as the next value. Read more
fn timeout(self, timeout: Duration) -> Timeout<Self>
[src][−]
Creates a new stream which allows self
until timeout
. Read more