Crate body_image_futio
source ·Expand description
Asynchronous HTTP integration for body-image.
The body-image-futio crate integrates the body-image crate with futures, http, hyper 0.12.x., and tokio crates for both client and server use.
-
Trait
RequestRecorder
extendshttp::request::Builder
for recording aRequestRecord
of varous body types, which can then be passed torequest_dialog
orfetch
. -
The
fetch
function runs aRequestRecord
and returns a completedDialog
using a single-use client and runtime forrequest_dialog
. -
The
request_dialog
function returns aFuture<Item=Dialog>
, given a suitablehyper::Client
reference andRequestRecord
. This function is thus more composable for complete tokio applications. -
AsyncBodySink
adapts aBodySink
for asynchronous input from a (e.g.hyper::Body
)Stream
. -
AsyncBodyImage
adapts aBodyImage
for asynchronous output as aStream
andhyper::body::Payload
. -
Alternatively,
UniBodySink
andUniBodyImage
offer zero-copyMemMap
support, using the customUniBodyBuf
item buffer type (instead of thehyper::Chunk
orBytes
). -
The
decode_res_body
and associated functions will decompress any supported Transfer/Content-Encoding of the response body and update theDialog
accordingly.
Structs
BodyImage
implementing the futures::Stream
and
hyper::body::Payload
traits.BodySink
implementing the futures::Sink
trait. This
allows a hyper::Body
(hyper::Chunk
item) stream to be forwarded
(e.g. via futures::Stream::forward
) to a BodySink
, in a fully
asynchronous fashion.http::Request
and recording. Note that other important getter
methods for RequestRecord
are found in trait implementation
RequestRecorded
.Bytes
and Mmap
memory
regions. Implements bytes::Buf
(mmap feature only).BodyImage
implementing the futures::Stream
and
hyper::body::Payload
traits, using the custom
UniBodyBuf
item buffer type (instead of
Bytes
) for zero-copy MemMap
support (mmap feature only).BodySink
implementing the futures::Sink
trait. This
allows a Stream<Item=UniBodyBuf>
to be forwarded (e.g. via
futures::Stream::forward
) to a BodySink
, in a fully asynchronous
fashion and with zero-copy MemMap
support (mmap feature only).Statics
Traits
http::request::Builder
, to enable recording key
portions of the request for the final Dialog
.Functions
Dialog
compressed with any
supported Encoding
, updated the dialog accordingly. The provided
Tunables
controls decompression buffer sizes and if the final
BodyImage
will be in Ram
or FsRead
. Returns Ok(true)
if the
response body was decoded, Ok(false)
if no or unsupported encoding,
or an error on failure.Encoding
,
using Tunables
for buffering and the final returned BodyImage
. If the
encoding is not supported (e.g. Chunked
or Brotli
, without the feature
enabled), returns None
.Dialog
. This
function constructs a default tokio Runtime
,
hyper_tls::HttpsConnector
, and hyper::Client
in a simplistic form
internally, waiting with timeout, and dropping these on completion.Chunked
encoding will be the first value if
found. At most one compression encoding will be the last value if found.hyper::Client
and RequestRecord
, return a
Future<Item=Dialog>
. The provided Tunables
governs timeout intervals
(initial response and complete body) and if the response BodyImage
will
be in Ram
or FsRead
.