wshobson avatar

Rust Async Patterns

A comprehensive guide to async Rust that goes beyond the basics. Covers production patterns like JoinSet for concurrent tasks, proper channel selection between mpsc/broadcast/oneshot, graceful shutdown with CancellationToken, and async trait implementations. The error handling section shows both anyhow and thiserror approaches with concrete examples. What I like here is the emphasis on real patterns you actually need in production, not just hello world async examples. The concurrency limiting with buffer_unordered and timeout wrappers address common pain points. Good reference when you're past the "add .await everywhere" stage and need to build robust async systems.

install copies · 90 days. Times the install command was copied on this site in the last 90 days, bots filtered.
13
skills.sh installs
21.9K
GitHub stars
42.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add wshobson/agents --skill rust-async-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

Rust Async Patterns

Production patterns for async Rust programming with Tokio runtime, including tasks, channels, streams, and error handling.

When to Use This Skill

  • Building async Rust applications
  • Implementing concurrent network services
  • Using Tokio for async I/O
  • Handling async errors properly
  • Debugging async code issues
  • Optimizing async performance

Core Concepts

1. Async Execution Model

Future (lazy) → poll() → Ready(value) | Pending
                ↑           ↓
              Waker ← Runtime schedules

2. Key Abstractions

ConceptPurpose
FutureLazy computation that may complete later
async fnFunction returning impl Future
awaitSuspend until future completes
TaskSpawned future running concurrently
RuntimeExecutor that polls futures

Quick Start

# Cargo.toml
[dependencies]
tokio = { version = "1", features = ["full"] }
futures = "0.3"
async-trait = "0.1"
anyhow = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"

Sponsors

Details

Repository
github.com/wshobson/agents
Categories
Debugging, Rust

More from wshobson/agents

All 174

Recommended

More Debugging
1vercel avatarnext-cache-components-optimizervercel/next.jsDrive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navig20.6Kskills.sh installs
2wshobson avatarsql-optimization-patternswshobson/agentsMaster SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debug20.4Kskills.sh installs
3jeffallan avatargolang-projeffallan/claude-skillsImplements concurrent Go patterns using goroutines and channels, designs and builds microservices with gRPC or REST, optimizes Go application performance with p19.5Kskills.sh installs
4madteacher avatarflutter-animationsmadteacher/mad-agents-skillsAdd, fix, refactor, debug, test, or explain Flutter animations and motion effects. Use when working with implicit animations such as AnimatedContainer, Animated15.5Kskills.sh installs
5github avatarchrome-devtoolsgithub/awesome-copilotExpert-level browser automation, debugging, and performance analysis using Chrome DevTools MCP. Use for interacting with web pages, capturing screenshots, analy15.4Kskills.sh installs
6jeffallan avatarkubernetes-specialistjeffallan/claude-skillsUse when deploying or managing Kubernetes workloads. Invoke to create deployment manifests, configure pod security policies, set up service accounts, define net14.6Kskills.sh installs