Expand description
Asynchronous HTTP integration for body-image.
The body-image-futio crate integrates body-image with futures, http, hyper, and tokio for both client and server use.
-
Trait
RequestRecorderextendshttp::request::Builderfor recording aRequestRecordof various body types, which can then be passed torequest_dialogorfetch. -
The
fetch()function runs aRequestRecordand returns a completedDialogusing a single-use client and runtime forrequest_dialog. -
The
request_dialog()function returns aFuturewithDialogoutput, given a suitablehyper::Clientreference andRequestRecord. This function is thus more composable for complete tokio applications. -
AsyncBodyImageadapts aBodyImagefor asynchronous output as aStreamandhttp_body::Body. -
AsyncBodySinkadapts aBodySinkfor asynchronous input from a (e.g.hyper::Body)Stream. -
The
decode_res_body()and associated functions will decompress any supported Transfer/Content-Encoding of the response body and update theDialogaccordingly.
§Optional Features
The following features may be enabled or disabled at build time. All are enabled by default.
mmap: Adds zero-copy memory map support, via a UniBodyBuf type usable
with all Stream and Sink types.
brotli: Adds the brotli compression algorithm to ACCEPT_ENCODINGS and
decompression support in decode_res_body.
hyper-http: Adds Hyper based fetch() and request_dialog()
functions, as well as a RequestRecorder implementation for
hyper::Body (its “default” http_body::Body type).
Structs§
- Async
Body Image - Adaptor for
BodyImage, implementing thefutures::Streamandhttp_body::Bodytraits. - Async
Body Sink - Adaptor for
BodySink, implementing thefutures::Sinktrait. - Dispatch
Body Image - Extends
AsyncBodyImageby further dispatching any blocking file read operations to ablocking_permit::DispatchPoolregistered with the current thread. - Dispatch
Body Sink - Extends
AsyncBodySinkby further dispatching any blocking file write operations to ablocking_permit::DispatchPoolregistered with the current thread. - Futio
Tunables - An additional set of tuning constants for asynchronous I/O, extending the
body_image::Tunablesset. - Futio
Tuner - A builder for
FutioTunables. - Lenient
Arbiter - A lenient arbiter that always allows blocking.
- Permit
Body Image - Extends
AsyncBodyImageby acquiring a blocking permit before performing any blocking file read operations. - Permit
Body Sink - Extends
AsyncBodySinkby acquiring a blocking permit before performing any blocking file write operations. - Request
Record - An
http::Requestand recording. - Stateful
Arbiter - A stateful arbiter that records the need to block and grants one-time allowances.
- UniBody
Buf - Provides zero-copy read access to both
Bytesand memory mapped regions (MemMapBuf). Implementsbytes::Buf(mmap feature only).
Enums§
- Blocking
- All possible states of a
BlockingArbiter. - Blocking
Policy - The policy for blocking operations.
- Futio
Error - Error enumeration for body-image-futio origin errors. This may be extended in the future so exhaustive matching is gently discouraged with an unused variant.
Statics§
- ACCEPT_
ENCODINGS - Appropriate value for the HTTP accept-encoding request header, including (br)otli when the brotli feature is configured.
- BROWSE_
ACCEPT - A browser-like HTTP accept request header value, with preference for hypertext.
- VERSION
- The crate version string.
Traits§
- Blocking
Arbiter - Trait for arbitration of where blocking operations are acceptable to the runtime.
- Input
Buf - Trait qualifying
Sink<Item>buffer requirements. - Output
Buf - Trait qualifying
StreamItem-type buffer requirments. - Request
Recorder - Extension trait for
http::request::Builder, to enable recording key portions of the request for the finalDialog. - Sink
Wrapper - Trait for generic construction of
Sinkwrapper types. - Stream
Wrapper - Trait for generic construction of
Streamwrapper types.
Functions§
- decode_
res_ body - Decode the response body of the provided
Dialogcompressed with any supportedEncoding, updated the dialog accordingly. - fetch
- Run an HTTP request to completion, returning the full
Dialog. - find_
chunked - Return true if the chunked Transfer-Encoding can be found in the headers.
- find_
encodings - Return a list of relevant encodings from the headers Transfer-Encoding and Content-Encoding.
- request_
dialog - Given a suitable
hyper::ClientandRequestRecord, return aFuturewithDialogoutput. - user_
agent - Return a generic HTTP user-agent header value for the crate, with version
Type Aliases§
- Flaw
- Conveniently compact type alias for dyn Trait
std::error::Error. - Split
Body Image - Extends
AsyncBodyImageby splitting buffers and yielding. - Yield
Body Image - Extends
AsyncBodyImageby periodically yielding.