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

Rust by Example: Real Repositories

Production codeExecution tracesArchitecture

Small examples teach syntax. Mature repositories teach how Rust’s mechanisms fit together under real constraints.

This book walks through production Rust codebases from the outside in. It starts with what a user calls, follows that operation across crates and modules, and stops at the boundary where the work is actually performed. Along the way, it explains why the types, ownership relationships, tasks, channels, and error paths have the shapes they do.

public operation
       │
       ▼
API and type boundary
       │
       ▼
shared abstraction
       │
       ▼
concrete implementation
       │
       ▼
I/O, operating system, or external service

The goal is not to inventory every file. It is to develop a repeatable way to answer:

  • Where does an operation enter the system?
  • Which values own the state it needs?
  • Which traits connect generic code to concrete behavior?
  • Where can execution suspend, fail, or be cancelled?
  • What must happen before a resource can be reused?

The current walkthroughs cover twenty-three contrasting systems:

  • SQLx combines generics, protocol state machines, async I/O, pools, worker threads, and cancellation-safe cleanup;
  • ripgrep uses synchronous parallelism, work stealing, worker-local state, and serialized output commits;
  • Aikido uses bounded Tokio pipelines, task-owned mutation, desired state, and reconciliation;
  • Axum adapts typed handlers into composable Tower services driven by Hyper and Tokio;
  • Vector compiles a dataflow DAG into Tokio tasks and bounded edges with explicit durability and acknowledgement semantics;
  • Helix serializes editor mutation while background jobs return owned results;
  • uv combines async preparation, resource-specific limits, in-flight deduping, atomic caches, and target locking;
  • rust-analyzer coordinates mutable inputs with cancellable read snapshots and demand-driven Salsa computation;
  • Linkerd2-proxy composes target-specialized Tower stacks around readiness, discovery, streaming completion, and graceful drain;
  • Nushell combines lazy structured iterators, explicit Rayon parallelism, and OS process lifecycle; and
  • Apalis adapts ordinary async functions into backend-independent durable job services with typed extraction, middleware, retry, and tracked shutdown;
  • Watchexec turns concurrent filesystem, signal, and keyboard observations into serialized policy and independently supervised child-process transitions;
  • sccache separates high request concurrency from bounded compiler-process and jobserver capacity;
  • Atuin turns offline local changes into encrypted append-only sync records;
  • Garage coordinates replicated object storage, repair, and bounded background work;
  • Zellij combines thread-owned session mutation with async PTY I/O and fair per-pane output handling;
  • Tokio implements task scheduling, waking, I/O readiness, timers, cancellation, and a separate blocking boundary; and
  • Deno connects V8 promises to typed Rust ops, native resources, Tokio-driven progress, and parallel worker isolates;
  • Bevy derives safe parallel ECS scheduling from typed system access;
  • godot-rust protects Rust ownership across an engine-controlled FFI lifecycle;
  • Quinn joins a deterministic QUIC state machine to async sockets and targeted stream wakeups;
  • DataFusion plans and executes partitioned Arrow batch streams under explicit memory accounting; and
  • Rerun carries typed Arrow components through concurrent ingestion, temporal storage, immediate-mode querying, and GPU rendering.