huiali/rust-skills/rust-async
Claude Code and agent skill by huiali/rust-skills
- community
Checking that the SKILL.md file is still in the repository.
Advanced async patterns expert. Handles Stream processing, backpressure control, select/join operations, cancellation, Future trait implementation, and async runtime optimization.
Install
npx vskill@latest install huiali/rust-skills/rust-asyncSKILL.md
Solution Patterns
Pattern 1: Stream Processing
When to use: Processing continuous data flows (websockets, file streams, API pagination).
Key insight: Streams are async iterators - pull-based, lazy evaluation.
Pattern 2: Backpressure Control
When to use: Prevent overwhelming downstream systems or resource exhaustion.
Trade-offs: Adds latency but prevents overload.
Pattern 3: Select Multiplexing
When to use: Waiting on multiple async operations, first-to-complete wins.
Gotcha: All branches must be cancellation-safe.
Pattern 4: Task Cancellation
When to use: Operations with time limits or user-requested cancellation.
Key insight: Cancellation is cooperative - requires yield points.
Workflow
Step 1: Choose Stream vs Iterator
Step 2: Design Concurrency Strategy
Step 3: Handle Cancellation
Join vs Try_Join
Join - Wait for All
Use when: All results needed regardless of individual failures.
Try_Join - Fail Fast
Use when: All operations must succeed, fail fast on errors.
Combined Pattern
Common Errors & Solutions
| Error | Cause | Solution | |
|---|---|---|---|
.await forgotten | Future not polled | Check all async fn calls have .await | |
| Cancellation unhandled | Task aborted mid-operation | Implement cooperative cancellation | |
| Missing backpressure | Unbounded concurrency | Use Semaphore or buffer_unordered | |
| Deadlock | Lock held across .await | Minimize lock scope, drop before await | |
| Async drop unsupported | Drop in async context | Use spawn for cleanup or blocking drop |
Backpressure Strategies
Strategy 1: Semaphore-Based
Pros: Precise control, easy to reason about Cons: Semaphore overhead
Strategy 2: Buffered Stream
Pros: Simple, built-in to StreamExt Cons: Less fine-grained control
Strategy 3: Channel-Based
Pros: Natural backpressure from bounded channel Cons: Extra copy/move overhead
Performance Tips
| Pattern | Performance Insight | |
|---|---|---|
select! | More lightweight than multiple tokio::spawn | |
buffer_unordered | More flexible than for_each_concurrent | |
.chunks() | Reduces per-item overhead for bulk operations | |
| Lock-free at await | Never hold locks across .await points | |
spawn_blocking | Use for CPU-bound work in async context |
Advanced: Future Trait
Implementing Future
When to implement: Custom async primitives, advanced control flow.
Gotcha: Must properly handle wakeup notifications.
Review Checklist
When reviewing async code:
- [ ] All async functions are properly
.awaited - [ ] Backpressure mechanisms in place for streams
- [ ] Cancellation handled cooperatively (yield points)
- [ ] No locks held across
.awaitpoints - [ ] Stream processing uses appropriate concurrency limits
- [ ] Error propagation uses
?or proper handling - [ ]
select!branches are cancellation-safe - [ ] Long-running tasks have timeout protection
- [ ] Resource cleanup happens even on cancellation
- [ ] CPU-bound work uses
spawn_blocking
Verification Commands
Common Pitfalls
1. Forgotten Await
Symptom: Future never executes, unexpected behavior
2. Unbounded Concurrency
Symptom: Resource exhaustion, system overload
3. Lock Across Await
Symptom: Deadlock, "future cannot be sent between threads safely"
4. Async Drop
Symptom: Cannot await in Drop impl
Related Skills
- rust-concurrency - Thread safety, Send/Sync basics
- rust-async-pattern - Async architecture patterns
- rust-ownership - Lifetime issues in async contexts
- rust-pin - Pin and self-referential types
- rust-performance - Async performance optimization
- rust-web - Async web frameworks (axum, actix)
Localized Reference
- Chinese version: SKILL_ZH.md - 完整中文版本,包含所有内容
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
- semgrepPassed, 100 of 100
- njsscanPassed, 100 of 100
- trufflehogPassed, 100 of 100
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/rust-async/SKILL.md
Popularity
- Repository stars
- 23
- Repository forks
- 4
- 7-day trend score
- 16
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 1 Apr 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/huiali/rust-skills/rust-async)