[][src]Struct body_image_futio::AsyncBodyImage

pub struct AsyncBodyImage { /* fields omitted */ }

Adaptor for BodyImage implementing the futures::Stream and hyper::body::Payload traits.

The Payload trait (plus Send) makes this usable with hyper as the B body type of http::Request<B> (client) or http::Response<B> (server). The Stream trait is sufficient for use via hyper::Body::with_stream.

Tunables::buffer_size_fs is used for reading the body when in FsRead state. BodyImage in Ram is made available with zero-copy using a consuming iterator. This implementation uses tokio_threadpool::blocking to request becoming a backup thread for blocking reads from FsRead state and when dereferencing from MemMap state (see below).

MemMap

While it works without complaint, it is not generally advisable to adapt a BodyImage in MemMap state with this Payload and Stream type. The Bytes part of the contract requires a owned copy of the memory-mapped region of memory, which contradicts the advantage of the memory-map. The cost is confirmed by the cargo bench stream benchmarks.

Instead use UniBodyImage for zero-copy MemMap support, at the cost of the adjustments required for not using the default hyper::Body type.

None of this applies, of course, if the mmap feature is disabled or if BodyImage::mem_map is never called.

Methods

impl AsyncBodyImage[src]

pub fn new(body: BodyImage, tune: &Tunables) -> AsyncBodyImage[src]

Wrap by consuming the BodyImage instance.

Note: BodyImage is Clone (inexpensive), so that can be done beforehand to preserve an owned copy.

Trait Implementations

impl RequestRecorder<AsyncBodyImage> for Builder[src]

impl Debug for AsyncBodyImage[src]

impl Stream for AsyncBodyImage[src]

type Item = Bytes

The type of item this stream will yield on success.

type Error = Error

The type of error this stream may generate.

impl Payload for AsyncBodyImage[src]

type Data = Cursor<Bytes>

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

type Error = Error

The error type of this stream.

Auto Trait Implementations

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> StreamExt for T where
    T: Stream + ?Sized
[src]

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