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

Rust fundamentalsProtocol ownershipRevision c8b02d1
  • Arc gives endpoint and connection handles shared ownership independent of any one future.
  • Mutex serializes each protocol state machine while allowing handles on many executor threads.
  • AtomicUsize distinguishes public live handles from the driver itself.
  • HashMap<StreamId, Waker> correlates readiness with exactly one blocked stream operation.
  • Option<Waker> represents at most one driver notification claim.
  • Pin<Box<dyn Future>> and trait objects erase runtime-specific timers and sockets at the narrow integration boundary.
  • Bytes shares immutable packet/stream storage cheaply.
  • enums preserve transport, application, reset, closed, 0-RTT, and local-close errors as separate states.

The types make the protocol’s ownership graph visible: socket → endpoint → connection → stream, with wake paths traveling back upward only when needed.