Expand description
Matier: a high-performance HTTP/1.1 + HTTP/2 client for tokio.
use http_body_util::BodyExt;
use matier::{Body, Client};
let client = Client::new();
let req = http::Request::get("http://127.0.0.1:8080/hello").body(Body::empty()).unwrap();
let resp = client.send(req).await?;
println!("status = {}", resp.status());
let mut body = resp.into_body();
let mut len = 0;
while let Some(frame) = body.frame().await {
if let Some(data) = frame?.data_ref() {
len += data.len(); // `BytesView` chunks are slices of the connection's read buffer
}
}
println!("{len} body bytes");The v0 stack is Dispatch (request validation) followed by the connection Pool. Timeout,
retry, metrics and decompression layers come later; compose them with Service.
Structs§
- Body
Sender - Producer half of
Body::channel. - Body
Timeout - Idle timeout between body chunks.
- Bytes
View - A view over a sequence of immutable bytes.
- Client
- An HTTP client. Cheap to clone (shares one connection pool).
- Client
Builder - Builder for
Client. - Connect
Config - Connection
Info - Response-side extension describing the connection that served the request.
- Error
- One error type for the whole client. Constructing one without a source does not allocate.
- H1Config
- HTTP/1.1 connection settings.
- H2Config
- HTTP/2 connection configuration.
- Noop
Observer - The default observer: does nothing,
enabled()is false. - Origin
Key - Connection identity. Precomputed telemetry attributes hang off the pool entry for this key.
- Origin
Stats - Snapshot of one origin’s pool, for diagnostics and tests.
- Pool
- The connection pool. Cheap to clone.
- Pool
Config - Pool limits and timeouts.
- Priority
- RFC 9218 priority. Defaults: urgency 3, non-incremental.
- Response
Timeout - Deadline for receiving the response head.
- TlsConfig
- TLS configuration. ALPN is managed by the transport:
rustlsoffersh2+http/1.1, and an http/1.1-only sibling (sharing the same session cache and verifier) is used whenalpn_h2is false. - UriTemplate
- Low-cardinality URI template for telemetry (
url.template).
Enums§
- Body
- Request body.
- Error
Kind - Incoming
- Response body produced by either protocol. An enum (not a
Box<dyn Body>) so responses need no extra allocation. - Protocol
- Negotiated application protocol.
- Recovery
- Whether and how a failed request may be retried (fetch/seatbelt
RecoveryInfoidea). - Scale
Reason - Why the pool changed the number of connections to an origin (see
Observer::pool_scaled). - Scheme
Traits§
- Observer
- Instrumentation hooks. All methods default to no-ops;
matier-otelimplements them. Called on hot paths: implementations must not block or allocate per call where avoidable. - Service
- An async operation from
IntoOut.