R

rust-async-patterns

by @wshobsonv
4.5(120)

このスキルは、Tokioランタイム、タスク、チャネル、ストリーム、エラー処理を含む、Rust非同期プログラミングのための本番レベルのパターンを提供します。開発者が高性能で高並行な非同期Rustアプリケーションを構築し、並行サービスにおけるエラーを効果的に処理し、コードのパフォーマンスを最適化することで、開発効率とシステムの安定性を向上させます。

rustasynctokioconcurrencybackendGitHub
インストール方法
npx skills add https://github.com/wshobson/agents --skill rust-async-patterns
compare_arrows

Before / After 効果比較

2
使用前

明確な非同期パターンガイドがない場合、Rust開発者は複雑な並行処理のデバッグ、デッドロック、パフォーマンスのボトルネックに直面し、開発期間の延長とシステムの不安定化を招きます。

使用後

これらの実証済みの非同期パターンを適用することで、開発者はデバッグ時間を大幅に短縮し、一般的な並行処理の問題を防ぎ、より高い自信と効率で堅牢で高性能なRustサービスを構築できます。

SKILL.md

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"
use tokio::time::{sleep, Duration};
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize tracing
    tracing_subscriber::fmt::init();

    // Async operations
    let result = fetch_data("https://api.example.com").await?;
    println!("Got: {}", result);

    Ok(())
}

async fn fetch_data(url: &str) -> Result<String> {
    // Simulated async operation
    sleep(Duration::from_millis(100)).await;
    Ok(format!("Data from {}", url))
}

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

Do's

  • Use tokio::select! - For racing futures
  • Prefer channels - Over shared state when possible
  • Use JoinSet - For managing multiple tasks
  • Instrument with tracing - For debugging async code
  • Handle cancellation - Check CancellationToken

Don'ts

  • Don't block - Never use std::thread::sleep in async
  • Don't hold locks across awaits - Causes deadlocks
  • Don't spawn unboundedly - Use semaphores for limits
  • Don't ignore errors - Propagate with ? or log
  • Don't forget Send bounds - For spawned futures

ユーザーレビュー (0)

レビューを書く

効果
使いやすさ
ドキュメント
互換性

レビューなし

統計データ

インストール数15.4K
評価4.5 / 5.0
バージョン
更新日2026年7月8日
比較事例2 件

ユーザー評価

4.5(120)
5
37%
4
43%
3
13%
2
5%
1
2%

この Skill を評価

0.0

対応プラットフォーム

🤖claude-code

タイムライン

作成2026年5月29日
最終更新2026年7月8日
🎁 Agent 知識カード
アンケート