Rust from Zero

18 lessons

Learn Rust fundamentals by building rune — a CLI-first password manager you will actually use. Ownership, borrowing, lifetimes, traits, async, error handling, and the type system — all taught through encrypted vaults, git-based sync, and a web UI.

Rust from Zero

what you'll learn

  • Build rune — a CLI-first password manager with encrypted vaults, git sync, and a web UI. A real tool, not a throwaway tutorial
  • Ownership, borrowing, and lifetimes — through problems that make them click, not contrived examples
  • Navigate and leverage Rust's crate ecosystem — clap, serde, tokio, axum, sqlx, git2, and more
  • Structure your application to be modular and extensible — modules, trait objects, storage backends, and clean separation between CLI and web
  • AES-256-GCM encryption, argon2 key derivation, and X25519 key exchange — why Rust's deterministic destruction makes it uniquely suited for crypto
  • Write tests from unit tests to integration tests to property-based fuzzing with proptest — all code ships with tests
  • Enforce domain invariants using Rust's type system — newtypes, enums, and exhaustive pattern matching that catch bugs at compile time
  • Async Rust with tokio and axum — run a web server alongside the CLI in the same codebase, with shared state via Arc<Mutex<>>
  • Authenticate and authorize users — sessions, middleware, protected routes, and per-user vault encryption
  • Read compiler errors like a conversation — the Rust compiler is your strictest and most helpful collaborator
  • Implement a robust error handling strategy — Result, thiserror, custom error enums, and the ? operator
  • SQLx compile-time checked queries against PostgreSQL — if it compiles, the SQL is valid

Learning Rust

Introduction

What rune is, why Rust, and how this book fits into the lighthouse learning path.

A Quick Look at Rust

Variables, mutability, functions, ownership basics, and reading compiler errors. Everything you need before we start building.

The Solo Vault

Your First Binary

Create the rune CLI with Cargo and clap. Subcommands, help output, and reading the master password from stdin.

Modeling the Vault

Design the Entry and Vault structs, serialize to JSON with serde, and understand who owns what.

Encryption

AES-256-GCM encryption, argon2 key derivation, and why Rust's deterministic destruction makes it uniquely good at crypto.

File I/O and Error Handling

Save and load the encrypted vault. Handle missing files, wrong passwords, and corrupted data with Result and thiserror.

CRUD and the Borrow Checker

Add, get, list, remove, edit. Passwords display as fixed-length masks. The borrow checker fights back — and wins.

The eh Command and Masking

rune eh shows the first 4 characters. Why fixed-length masking matters — password length is information leakage.

Password Generation

Generate secure passwords with configurable rules. Copy to clipboard with auto-clear. Traits, closures, and Option.

Git Storage and Sync

Auto-commit on changes, version history, push/pull sync, and conflict detection. Trait objects for storage backends.

The Web Layer

The Web Server

Add an axum HTTP server alongside the CLI. Async Rust, tokio, Arc<Mutex<>>, and shared state.

Database and SQLx

PostgreSQL for user accounts. Compile-time checked SQL queries, connection pools, and migrations.

Authentication

Email/password signup, argon2 hashing, sessions, protected routes, and the newtype pattern.

Ship It

Testing

Unit tests for crypto, integration tests for vault operations, and property-based testing with proptest.

Polish and Release

Shell completions, JSON output, cross-compilation, release builds, and binary optimization.