Skip to main content

hclient_core/
lib.rs

1//! Plugin contract for hclient: the traits a backend, a runtime or a
2//! resolver implements, and the vocabulary types they exchange.
3//!
4//! # The `Send` rule
5//!
6//! **The seam traits declare no `Send`/`Sync` bounds.** `Transport`,
7//! `Timer` and the middleware traits leave Send-ness to auto-traits
8//! through `impl Future`, because a bound declared where the type is
9//! abstract is forced on every backend — including ones that cannot meet
10//! it, such as a single-threaded embedded runtime whose connect future
11//! holds a `RefCell`.
12//!
13//! Bounds do appear in three places, and each is a value a caller hands
14//! over rather than a demand on an implementor:
15//!
16//! - [`Error`]'s source is `Send + Sync`, or a client could not build an
17//!   error from a backend's at all.
18//! - [`RequestBody`]'s rewind factory and streaming arm.
19//! - [`unversioned::erased`]'s two aliases, which a facade writes at its
20//!   own use site to put a transport behind an `Arc`. It is **not a
21//!   seam**: a blanket impl covers every `Transport`, so no backend
22//!   implements or is taxed by it, and one that cannot meet the bound is
23//!   refused at a constructor rather than at a trait.
24//!
25//! Every such site carries a `send-bound-exception` marker naming the
26//! amendment that admits it, and
27//! `scripts/no-send-or-sync-in-the-core-surface.sh` fails closed on one
28//! that does not. `grep` is therefore the authority on which sites exist;
29//! this list says what kind they are.
30#![forbid(unsafe_code)]
31
32mod body;
33mod caps;
34mod error;
35mod host;
36pub mod unversioned;
37
38pub use body::{RequestBody, RetryKind, RewindFactory};
39pub use caps::{
40    AllowEarlyData, CancelSupport, Capabilities, DecompressionSupport, EarlyDataSupport,
41    RedirectSupport, RequireVersion, ReuseSupport, TimeoutSupport, Timeouts, TlsSupport,
42    UnsupportedCapability, VersionNotAvailable, check_version,
43};
44pub use error::{Error, ErrorKind, Phase};
45pub use host::bare_host;