Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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.
  • HashMap stores routers, endpoints, caches, and label-indexed metrics.
  • Duration makes queue, detection, idle, failfast, and request timeouts distinct.
  • Option<T> and Conditional<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.