HTTP server
Axum + Tokio + tower-http
Typed extractors/state and Tower middleware compose with Tokio networking.
Limits: Configure limits, timeout/error mapping and graceful shutdown. Blocking work must not monopolize async workers.
Services where runtime control and explicit resource handling matter.
Axum · Tokio · SQLx · PostgreSQL
These recipes and dependency combinations need checking in your actual project before you rely on them.
Paste the guide address into your agent chat, together with what you want to build.
Use cases: Native network services; resource-sensitive APIs; services sharing a Rust core.
Generator documentation reviewed: 2026-10-18. Evidence: documentation-reviewed; commands not executed.
Use when: A new Rust service needs a new directory.
Working directory: /path/to/workspace (existing local source parent)
Generate the executable package baseline.
cargo new project --binUse when: An existing source directory has no Cargo.toml and must become a package; choose this instead of cargo new.
Working directory: /path/to/workspace/project (existing directory without Cargo.toml)
Initialize a binary package in place.
cargo init --binUse when: Only when SQLx is selected and owns schema migrations; metadata applies when checked query macros are used.
Working directory: /path/to/workspace/project (matching sqlx-cli installed)
Create an editable migration file.
sqlx migrate add initialWorking directory: /path/to/workspace/project (DATABASE_URL targets a disposable database; migration SQL reviewed)
Apply migrations to the disposable database.
sqlx migrate runWorking directory: /path/to/workspace/project (checked query macros and matching disposable schema available)
Generate offline query metadata.
cargo sqlx prepareChoose the tools your application needs. The brief includes your selections, their purpose and their limits; the complete guide keeps all recommendations and sources.
Axum + Tokio + tower-http
Typed extractors/state and Tower middleware compose with Tokio networking.
Limits: Configure limits, timeout/error mapping and graceful shutdown. Blocking work must not monopolize async workers.
PostgreSQL + SQLx; sqlx-cli migrations
SQL-oriented async access with optional checked query macros and migration tooling.
Limits: Select runtime/TLS/database features for the resolved release. Checked macros need a database or maintained offline metadata; runtime queries are not compile-time checked.
Serde-backed settings + config
Typed settings plus structured events/spans.
Limits: Set precedence explicitly; validate semantics; install a tracing subscriber; never log secrets.
tracing + configured subscriber
Typed settings plus structured events/spans.
Limits: Set precedence explicitly; validate semantics; install a tracing subscriber; never log secrets.
cargo test; rustfmt; Clippy; cargo audit
Compiler, style, behavior and known-advisory checks complement each other.
Limits: Audit coverage is advisory-driven; compile success does not establish behavior or security. Test supported feature combinations rather than blindly enabling incompatible features.
None for request-only service; Restate Rust SDK when durable workflows are required
Durable handlers and persisted workflow progress address work outliving a process.
Limits: Requires a Restate service and adoption test. Journal external operations correctly; idempotency and business transactions remain explicit. Tokio tasks alone are not durable.
cargo build --release --locked in a target-specific build pipeline
Reproducible dependency resolution from committed lockfile; native executable artifact.
Limits: Not universally static: verify libc, TLS/native libraries, target support, certificates and container runtime needs.
jsonwebtoken + selected identity provider contract
Typed claims and signature checks fit JWT-bearing service APIs
Limits: Configure accepted algorithms, issuer/audience, expiry and trusted key rotation; select required crypto features for resolved release. This is a verifier, not an OIDC login/session solution; opaque tokens need provider introspection.
lettre + project-selected SMTP provider
Typed mail construction and SMTP transport support application messages
Limits: Configure TLS, sender credentials and timeouts; send required mail through durable jobs with duplicate protection. Validate chosen async/runtime features in Rust; delivery receipts and bounces need provider handling.
AWS SDK for Rust S3 client
Durable object storage avoids dependence on service-local disk
Limits: Configure runtime credentials, region and least-privilege bucket access; authorize object keys and uploads, bound size/concurrency and define retention. Test multipart cleanup and selected provider compatibility.
Axum WebSocket extractor
WebSocket support fits bidirectional connected clients
Limits: Enable the documented module/feature; authorize handshake and every protected message, bound queues/message size and implement heartbeat/shutdown. Socket delivery is not durable history; define reconnect/resync.
Build with the stack’s strengths
Recommendation: Axum/Tower owns request extraction and middleware; domain functions return explicit errors; Tokio drives async I/O; SQLx pools and transactions own database access. Track child tasks and cancellation separately from persisted jobs. A Tokio channel coordinates tasks inside one live process and cannot recover accepted work after a crash.
Version scope: Reviewed docs expose Axum 0.8.9, Tokio 1.53.2 and SQLx 0.9.0 on 11 October 2026; Rust std docs show 1.99.0. These are documentation scopes, not a qualified composition or an automatic upgrade recommendation. Record rust-toolchain.toml, Cargo.lock, enabled features, SQLx CLI compatibility and database version before implementation. · Reviewed 2026-10-11 · Evidence: documentation-reviewed · Source: inputs/research/migrations-systems.json
For an existing application
These are documented options and proposed checks. Inspect the actual source application before adopting a transition.
Capture the old SQL schema, transactions, tenant filters, nullable values and database engine behavior.
Recommendation: keep existing schema ownership and backward-compatible columns; run SQLx reads for a selected boundary before transferring its writer. Generate metadata against exactly the reviewed migration state.
Recommendation: SQLx pooled access with transaction-scoped domain changes; query! checks literals against a live build schema or checked-in .sqlx metadata. Keep database engine choice independent of the Rust rewrite.
Recommendation: route writes back while retaining additive schema and a previous compatible binary. Delay destructive migrations; reconcile new-only persisted values before rollback.
Compile-time query/type checks can expose SQL/API mismatches before deployment.
Requires: Query macros/features and metadata match the chosen engine and schema; nullable results and dynamic queries receive runtime checks.
Tradeoffs: Dynamic SQL is outside macro checking; stale offline metadata can compile; schema ownership and deployment order still need controls.
Preserve old broker serialization, acknowledgement, delayed/retry states, concurrency and effect IDs. Durable Redis workers cannot be replaced transparently by tokio::spawn.
Recommendation: Rust commits an outbox intent in its domain transaction; a replay-safe relay submits to the retained queue/worker interface. Existing workers retain queue ownership while new job kinds are qualified. This outbox design is inferred, not a shipped Axum feature.
Recommendation: keep proven durable workers until a chosen Rust queue implementation is qualified for retries, scheduling, leases and crashes. River current Ruby docs describe a shared schema with Rust; that statement alone does not qualify a Rust worker API or migration.
Recommendation: stop the new producer, let accepted outbox entries settle and retain the old worker. Roll back traffic only after ambiguous effects are reconciled; avoid consuming a queue with incompatible handlers.
A retained worker boundary allows the HTTP layer to change without dropping backlog or broker guarantees.
Requires: Same-transaction outbox intent; stable relay/effect IDs; explicit payload translator; observed delivery and backlog ownership.
Tradeoffs: Two runtimes and a relay add operations; delivery may repeat; a SQLx transaction alone does not atomically submit to Redis.
Define HTTP admission/error behavior, task ownership, shutdown deadline and behavior for unavoidable CPU/blocking operations.
Recommendation: retain old routing while introducing Tower admission bounds and CancellationToken/TaskTracker-based ownership for a coherent endpoint cohort. Benchmark equivalent resource limits and durability before attributing gains to Rust.
Recommendation: bounded async work, cooperative cancellation, explicit shutdown notification plus tracked task completion, and SQLx pool close. For untrusted/hard-deadline native work, isolate it in a process whose termination contract is tested.
Recommendation: return the cohort to the previous service and reconcile persisted outcomes. Do not simply retry every cancelled request; its external effect may already have occurred.
Tracked tasks and explicit admission limits make resource use and planned termination easier to reason about.
Requires: Every child task is tracked; limits include waiting work; cancellation-safe I/O and shutdown budget are verified.
Tradeoffs: spawn_blocking closures may continue after timeout; killing a process still requires durable recovery and external-effect reconciliation.
Preserve subscriptions, authorization revocation, event versions, reconnect behavior and cross-instance fan-out.
Recommendation: keep the existing shared broker while a Rust gateway serves entire room/tenant cohorts; adapters translate existing messages without dual-emitting user effects. Test cross-runtime publication in both directions.
Recommendation: Axum WebSocket transport and bounded per-client queues. Tokio broadcast is appropriate only for local ephemeral fan-out with explicit Lagged handling; use durable state/event history to resync clients when loss is unacceptable.
Recommendation: route the whole cohort back and retain the shared broker/protocol. Resynchronize from authoritative durable records; local channel state cannot be restored from a previous binary.
Local bounded fan-out can prevent slow receivers from retaining unbounded memory.
Requires: Overflow/disconnect/resync policy exists; replica routing and shared fan-out remain covered; every broadcast error is handled.
Tradeoffs: Tokio broadcast is process-local; old messages are evicted when capacity is exceeded; it is not a durable cross-node broker.
Run these in the configured application. They are instructions, not recorded passes.
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked
cargo audit
sqlx migrate info
cargo sqlx prepare --check
cargo build --release --lockedOriginal source review: 2026-10-10. Core guidance rechecked: 2026-10-13. Check scope.