Expand description
Plugin contract for hclient: the traits a backend, a runtime or a resolver implements, and the vocabulary types they exchange.
§The Send rule
The seam traits declare no Send/Sync bounds. Transport,
Timer and the middleware traits leave Send-ness to auto-traits
through impl Future, because a bound declared where the type is
abstract is forced on every backend — including ones that cannot meet
it, such as a single-threaded embedded runtime whose connect future
holds a RefCell.
Bounds do appear in three places, and each is a value a caller hands over rather than a demand on an implementor:
Error’s source isSend + Sync, or a client could not build an error from a backend’s at all.RequestBody’s rewind factory and streaming arm.unversioned::erased’s two aliases, which a facade writes at its own use site to put a transport behind anArc. It is not a seam: a blanket impl covers everyTransport, so no backend implements or is taxed by it, and one that cannot meet the bound is refused at a constructor rather than at a trait.
Every such site carries a send-bound-exception marker naming the
amendment that admits it, and
scripts/no-send-or-sync-in-the-core-surface.sh fails closed on one
that does not. grep is therefore the authority on which sites exist;
this list says what kind they are.
Modules§
- unversioned
- Semver quarantine
Structs§
- Allow
Early Data - The caller’s per-request statement that this request may go into TLS 1.3 early data (0-RTT).
- Capabilities
- What the transport can do in this process, right now.
- Error
Cloneis deliberate: reqwest’s opaque, unclonable error is a source of constant complaints (reqwest#1053).- Require
Version - The caller’s per-request statement that this request needs a particular HTTP version, and must fail rather than go out over another one.
- Timeout
Support - Timeouts
- The timeout triple —
wasi:http’s shape, the richest of the ambient models. - Unsupported
Capability - A setting the chosen transport cannot honor.
- Version
NotAvailable - A
RequireVersiondemand the connection in hand does not satisfy.
Enums§
- Cancel
Support - Whether dropping the future returned by
Transport::executestops the exchange — see that method’s doc comment for the contract itself, of which this enum is the one honest way out. - Decompression
Support - Whether the transport hands back a response body it has already decoded, or the bytes exactly as the server put them on the wire.
- Early
Data Support - Whether a transport can put a request into TLS 1.3 early data (0-RTT).
- Error
Kind - The error’s category. Exists so the consumer doesn’t have to classify
errors by substring-matching on
Display. - Phase
- Redirect
Support - Who follows a redirect chain: nobody,
Client, or the backend. - Request
Body - A request body with an explicit replay contract.
- Retry
Kind - Whether this body can be replayed — known before sending.
- Reuse
Support - Whether a request may travel over a connection an earlier request already used, or whether every request opens a socket of its own.
- TlsSupport
Functions§
- bare_
host - The host a URI names, with an IPv6 literal’s brackets removed.
- check_
version - The one comparison, shared by every transport that honours a demand.
Type Aliases§
- Rewind
Factory Send + Syncbounds — a documented exception to the crate invariant “declareSend/Syncnowhere” (spec amendment-C2, sibling of C1 oncrate::Error). Without themRequestBodywould be!Send, sohttp::Request<RequestBody>would be!Send, so the futureTransport::executereturns would be!Sendfor every backend —tokio::spawn(client.get(u).send())would never build.Syncis only needed here, forArc:Arc<T>: SendrequiresT: Send + Sync, whereasBox<T>: Send(seeRequestBody::Streaming) requires onlyT: Send.