Skip to main content

Crate hclient_core

Crate hclient_core 

Source
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 is Send + 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 an Arc. It is not a seam: a blanket impl covers every Transport, 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§

AllowEarlyData
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
Clone is deliberate: reqwest’s opaque, unclonable error is a source of constant complaints (reqwest#1053).
RequireVersion
The caller’s per-request statement that this request needs a particular HTTP version, and must fail rather than go out over another one.
TimeoutSupport
Timeouts
The timeout triple — wasi:http’s shape, the richest of the ambient models.
UnsupportedCapability
A setting the chosen transport cannot honor.
VersionNotAvailable
A RequireVersion demand the connection in hand does not satisfy.

Enums§

CancelSupport
Whether dropping the future returned by Transport::execute stops the exchange — see that method’s doc comment for the contract itself, of which this enum is the one honest way out.
DecompressionSupport
Whether the transport hands back a response body it has already decoded, or the bytes exactly as the server put them on the wire.
EarlyDataSupport
Whether a transport can put a request into TLS 1.3 early data (0-RTT).
ErrorKind
The error’s category. Exists so the consumer doesn’t have to classify errors by substring-matching on Display.
Phase
RedirectSupport
Who follows a redirect chain: nobody, Client, or the backend.
RequestBody
A request body with an explicit replay contract.
RetryKind
Whether this body can be replayed — known before sending.
ReuseSupport
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§

RewindFactory
Send + Sync bounds — a documented exception to the crate invariant “declare Send/Sync nowhere” (spec amendment-C2, sibling of C1 on crate::Error). Without them RequestBody would be !Send, so http::Request<RequestBody> would be !Send, so the future Transport::execute returns would be !Send for every backend — tokio::spawn(client.get(u).send()) would never build. Sync is only needed here, for Arc: Arc<T>: Send requires T: Send + Sync, whereas Box<T>: Send (see RequestBody::Streaming) requires only T: Send.