huiali/rust-skills/rust-async-pattern
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 covering Stream implementation, zero-copy buffers, tokio::spawn lifetimes, plugin system scheduling, tonic streaming, and async lifetime management.
Install
npx vskill@latest install huiali/rust-skills/rust-async-patternSKILL.md
Solution Patterns
Pattern 1: Stream with Internal Buffer (Worker + Channel)
Pattern 2: tokio::spawn with Non-'static Lifetimes (Arena Pattern)
Pattern 3: Plugin System with Actor Pattern (Event Loop)
Pattern 4: Zero-Copy with Owned Snapshots
Pattern 5: Tonic Streaming with Snapshot Pattern
Architecture Patterns
When to Use Each Pattern
| Pattern | Use Case | Pros | Cons | |
|---|---|---|---|---|
| Worker + Channel | Stream with internal state | Clean separation, no lifetime issues | Extra allocation for snapshots | |
| Arena + Index | Plugin systems, tokio::spawn | Can spawn tasks, zero-copy possible | Complex lifecycle management | |
| Actor Event Loop | Coordinated scheduling | No spawn needed, backpressure control | Single-threaded per actor | |
| Bytes (Arc) | Network buffers | True zero-copy via reference counting | Reference counting overhead | |
| Owned Snapshots | API boundaries | Simple, always works | Copies data |
Workflow
Step 1: Identify Lifetime Constraint
Step 2: Choose Architecture
Step 3: Validate Constraints
Review Checklist
When implementing advanced async patterns:
- [ ] Stream::Item doesn't borrow from self
- [ ] All tokio::spawn tasks are 'static
- [ ] No self-referential pointers (use indices instead)
- [ ] Worker/actor pattern separates buffer ownership
- [ ] API boundaries use owned data (DTO pattern)
- [ ] Zero-copy only where performance critical
- [ ] Backpressure handled with bounded channels
- [ ] Channel capacity configured (not unbounded)
- [ ] Arena cleanup prevents memory leaks
- [ ] Error handling doesn't panic in streams
Verification Commands
Common Pitfalls
1. Stream Returning Borrowed Data
Symptom: "hidden type captures lifetime that does not appear in bounds"
2. Spawning Non-'static Future
Symptom: "borrowed data escapes outside of method"
3. Blocking Operations in Async
Symptom: Task blocks event loop, other tasks can't progress
Decision Matrix
When to Spawn vs Event Loop
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/rust-async-pattern/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 30 Mar 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-pattern)