본문으로 건너뛰기
Skillpedia
일반 코딩41k · #6800

rust-async-patterns

하는 일

이 스킬은 Rust에서 비동기 코드(async)를 사용해 프로그래밍하는 방법을 가르칩니다. Tokio 같은 도구를 사용해 프로그램을 멈추지 않으면서 여러 일을 동시에 처리하는 방법을 다룹니다.

사용하는 경우

  • ✓여러 일을 동시에 해야 하는 Rust 프로그램을 만들 때.
  • ✓많은 연결을 처리하는 네트워크 시스템을 만들 때.
  • ✓비동기 Rust 코드의 성능을 디버깅하거나 최적화할 때.

스킬 링크

https://github.com/wshobson/agents/blob/main/plugins/systems-programming/skills/rust-async-patterns/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/wshobson/agents/blob/main/plugins/systems-programming/skills/rust-async-patterns/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Rust 프로그램이 두 가지 일을 동시에 기다리고, 먼저 끝나는 쪽의 결과를 받게 하려면 어떻게 해야 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

Rust에서 비동기 코드가 어떻게 작동하는지 기본 개념을 설명합니다. '태스크'가 병렬로 실행되는 방식과, 나중에 완료될 계산인 '퓨처'를 쓰는 방법을 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

Concept Purpose
Future Lazy computation that may complete later
async fn Function returning impl Future
await Suspend until future completes
Task Spawned future running concurrently
Runtime Executor 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
자주 묻는 질문

Rust에서 'async'란 무엇인가요?

시간이 걸리는 일(예: 인터넷 응답)을 기다리는 동안 다른 일을 할 수 있게 하는 코드 작성 방식입니다. 프로그램 전체가 멈추지 않습니다.

Tokio란 무엇인가요?

Rust에서 비동기 코드를 효율적으로 관리하고 실행하는 인기 있는 도구입니다.

비동기 Rust의 '태스크'란 무엇인가요?

다른 코드와 독립적으로, 그리고 동시에 실행될 수 있는 비동기 코드 조각입니다.

상세 정보

작성자의 원본 설명

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.

repo: wshobson/agents

인기도

GitHub 스타
41k
순위
#6800
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬