Rust Async Patterns
Unverified●30/40Claude Code◐PartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor◐PartialPlain prose you can paste in — but no Cursor rules file
Codex◐PartialPlain prose you can paste in — but no AGENTS.md
Gemini CLI◐PartialPlain prose you can paste in
Copilot◐PartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add rust-async-patternsWho is stuck, and on what
Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code.
The whole source
Frontmatter — 2 properties
| name | rust-async-patterns |
|---|---|
| description | Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code. |
| 1 | --- |
| 2 | name: rust-async-patterns |
| 3 | description: Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code. |
| 4 | ---A5 — No allowed-tools declared — no way to tell what this skill may touch |
| 5 | |
| 6 | # Rust Async Patterns |
| 7 | |
| 8 | Production patterns for async Rust programming with Tokio runtime, including tasks, channels, streams, and error handling. |
| 9 | |
| 10 | ## When to Use This Skill |
| 11 | |
| 12 | - Building async Rust applications |
| 13 | - Implementing concurrent network services |
| 14 | - Using Tokio for async I/O |
| 15 | - Handling async errors properly |
| 16 | - Debugging async code issues |
| 17 | - Optimizing async performance |
| 18 | |
| 19 | ## Core Concepts |
| 20 | |
| 21 | ### 1. Async Execution Model |
| 22 | |
| 23 | ``` |
| 24 | Future (lazy) → poll() → Ready(value) | Pending |
| 25 | ↑ ↓ |
| 26 | Waker ← Runtime schedules |
| 27 | ``` |
| 28 | |
| 29 | ### 2. Key Abstractions |
| 30 | |
| 31 | | Concept | Purpose | |
| 32 | | ---------- | ---------------------------------------- | |
| 33 | | `Future` | Lazy computation that may complete later | |
| 34 | | `async fn` | Function returning impl Future | |
| 35 | | `await` | Suspend until future completes | |
| 36 | | `Task` | Spawned future running concurrently | |
| 37 | | `Runtime` | Executor that polls futures | |
| 38 | |
| 39 | ## Quick Start |
| 40 | |
| 41 | ```toml |
| 42 | # Cargo.toml |
| 43 | [dependencies] |
| 44 | tokio = { version = "1", features = ["full"] } |
| 45 | futures = "0.3" |
| 46 | async-trait = "0.1" |
| 47 | anyhow = "1.0" |
| 48 | tracing = "0.1" |
| 49 | tracing-subscriber = "0.3" |
| 50 | ``` |
| 51 | |
| 52 | ```rust |
| 53 | use tokio::time::{sleep, Duration}; |
| 54 | use anyhow::Result; |
| 55 | |
| 56 | #[tokio::main] |
| 57 | async fn main() -> Result<()> { |
| 58 | // Initialize tracing |
| 59 | tracing_subscriber::fmt::init(); |
| 60 | |
| 61 | // Async operations |
| 62 | let result = fetch_data("https://api.example.com").await?; |
| 63 | println!("Got: {}", result); |
| 64 | |
| 65 | Ok(()) |
| 66 | } |
| 67 | |
| 68 | async fn fetch_data(url: &str) -> Result<String> { |
| 69 | // Simulated async operation |
| 70 | sleep(Duration::from_millis(100)).await; |
| 71 | Ok(format!("Data from {}", url)) |
| 72 | } |
| 73 | ``` |
| 74 | |
| 75 | ## Detailed patterns and worked examples |
| 76 | |
| 77 | Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient. |
| 78 | |
| 79 | ## Best Practices |
| 80 | |
| 81 | ### Do's |
| 82 | |
| 83 | - **Use `tokio::select!`** - For racing futures |
| 84 | - **Prefer channels** - Over shared state when possible |
| 85 | - **Use `JoinSet`** - For managing multiple tasks |
| 86 | - **Instrument with tracing** - For debugging async code |
| 87 | - **Handle cancellation** - Check `CancellationToken` |
| 88 | |
| 89 | ### Don'ts |
| 90 | |
| 91 | - **Don't block** - Never use `std::thread::sleep` in async |
| 92 | - **Don't hold locks across awaits** - Causes deadlocks |
| 93 | - **Don't spawn unboundedly** - Use semaphores for limits |
| 94 | - **Don't ignore errors** - Propagate with `?` or log |
| 95 | - **Don't forget Send bounds** - For spawned futures |
| 96 |
Reviews
Installed this one?Write the first review and take the Trailblazer badge.
Alternatives
Subagent Driven DevelopmentUse when executing implementation plans with independent tasks in the current session◐◐◐◐◐●36/40Python Code Style & DocumentationPython code style, linting, formatting, naming conventions, and documentation standards. Use when writing new code, reviewing style, configuring linters, writing docstrings, or establishing project standards.◐····●35/40Competitor Price Analysis 💲Competitor pricing strategy analysis and market positioning. Price mapping, pricing gaps identification, elasticity signals evaluation, and strategic pricing optimization. Use when the user asks about competitor pricing, price analysis, pricing strategy, or co◐····●34/40Competitor Price Tracker 📊Set up competitor price tracking and monitoring workflows. Track price changes, detect promotions, analyze pricing patterns, and get alerts for competitive price movements.◐····●34/40