The Standard Library as Architecture
SocketAddr,IpAddr, and newtypes encode transport identity without strings.- tuples and small target structs accumulate typed context as a connection crosses stacks.
Arc<T>shares immutable policy, TLS configs, metrics families, and retry budgets.HashMapstores routers, endpoints, caches, and label-indexed metrics.Durationmakes queue, detection, idle, failfast, and request timeouts distinct.Option<T>andConditional<T, Reason>distinguish absence from an explicitly disabled capability with a reason.Pin<Box<dyn Future + Send>>erases futures only where runtime storage requires it.- RAII body wrappers observe end-of-stream or early drop to finish metrics and permits.
Newtypes are especially important: local versus remote addresses, server versus client TLS, logical versus concrete destinations, and inbound versus outbound labels are compile-time distinctions despite similar underlying data.