Skip to main content

Crate matier

Crate matier 

Source
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§

BodySender
Producer half of Body::channel.
BodyTimeout
Idle timeout between body chunks.
BytesView
A view over a sequence of immutable bytes.
Client
An HTTP client. Cheap to clone (shares one connection pool).
ClientBuilder
Builder for Client.
ConnectConfig
ConnectionInfo
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.
NoopObserver
The default observer: does nothing, enabled() is false.
OriginKey
Connection identity. Precomputed telemetry attributes hang off the pool entry for this key.
OriginStats
Snapshot of one origin’s pool, for diagnostics and tests.
Pool
The connection pool. Cheap to clone.
PoolConfig
Pool limits and timeouts.
Priority
RFC 9218 priority. Defaults: urgency 3, non-incremental.
ResponseTimeout
Deadline for receiving the response head.
TlsConfig
TLS configuration. ALPN is managed by the transport: rustls offers h2 + http/1.1, and an http/1.1-only sibling (sharing the same session cache and verifier) is used when alpn_h2 is false.
UriTemplate
Low-cardinality URI template for telemetry (url.template).

Enums§

Body
Request body.
ErrorKind
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 RecoveryInfo idea).
ScaleReason
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-otel implements them. Called on hot paths: implementations must not block or allocate per call where avoidable.
Service
An async operation from In to Out.

Type Aliases§

Result