rust-async-patterns
快速學習非同步 Rust 模式
非同步 Rust 可能很難結構化和除錯。這個技能提供清晰的 Tokio 任務、通道、流和錯誤模式。
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「rust-async-patterns」。 Explain how to limit concurrency for async HTTP requests in Tokio.
預期結果:
- Use a stream over URLs and apply buffer_unordered with a limit
- Collect results and handle errors per request
- Avoid unbounded spawning to protect memory and sockets
正在使用「rust-async-patterns」。 Show me how to coordinate between async tasks using channels.
預期結果:
- Use mpsc::channel for one-to-one communication between producer and consumer
- Use broadcast::channel when multiple consumers need the same message
- Use oneshot::channel when you need a single response from a spawned task
正在使用「rust-async-patterns」。 How do I handle errors in async Rust code properly?
預期結果:
- Use anyhow for application-level errors with context chaining
- Use thiserror for library code to create custom error types
- Wrap operations with timeout to prevent indefinite hanging
安全審計
安全Pure educational documentation containing Rust async programming examples. All static findings are false positives: 'process spawn' refers to tokio::spawn for async task management (not command execution), 'backtick execution' refers to markdown code formatting, and 'weak cryptographic algorithm' refers to keywords in documentation fields. The skill contains no tool definitions, file access, network calls, or command execution capabilities.
風險因素
⚙️ 外部命令 (39)
品質評分
你能建構什麼
建構並發服務
在非同步 Rust 服務中應用結構化模式來進行任務編排、錯誤處理和關機。
除錯非同步死結
使用追蹤指南和常見陷阱來診斷卡住的任務和鎖的不當使用。
學習非同步概念
透過簡短且聚焦的範例學習 future、await、流和通道。
試試這些提示
提供一個簡短的 Tokio 非同步 main 範例,包含追蹤和模擬的非同步呼叫。每個步驟用一句話說明。
展示一個使用 Tokio 或 future 流來限制 URL 清單中並發非同步任務數量的模式。
說明使用 CancellationToken 和關機廣播通道來實現優雅關機的方法。
提供一個儲存庫的非同步特徵設計,包含 get、save 和 delete 方法,並說明特徵物件的使用方式。
最佳實務
- 使用 tokio::select! 來安全地競爭 futures
- 優先使用通道進行協調,而非共享的可變狀態
- 為非同步任務加入追蹤以提高可觀測性
避免
- 在非同步程式碼中呼叫阻塞函數如 std::thread::sleep
- 在 await 點之間持有 mutex 或 rwlock 守護
- 產生無限數量的任務而沒有並發限制
常見問題
這與目前的 Tokio 版本相容嗎?
它會產生完整的應用程式碼嗎?
我可以在現有的儲存庫中使用它嗎?
它會存取或儲存我的資料嗎?
如果我的非同步程式碼仍然卡住怎麼辦?
這與一般的非同步指南有何不同?
開發者詳情
作者
wshobson授權
MIT
儲存庫
https://github.com/wshobson/agents/tree/main/plugins/systems-programming/skills/rust-async-patterns引用
main
檔案結構
📄 SKILL.md