rust-async-runtime

Implements Rust asynchronous programming patterns using tokio runtime, channels, and task spawning.

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/luckyegg168/rust-skill --skill rust-async-runtime-luckyegg168
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust-async-runtime
Source: https://github.com/luckyegg168/rust-skill/tree/main/rust-skills/rust-async-runtime
Command: npx skills add https://github.com/luckyegg168/rust-skill --skill rust-async-runtime-luckyegg168

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires tokio, tokio-stream, tokio-util, futures, async-trait, pin-project-lite, and includes references (resource) components.

What problem does it solve? Writing correct async Rust code is difficult: developers struggle with runtime selection, blocking the executor, channel design, deadlocks from holding locks across await points, and cryptic Send trait errors. This Skill provides structured guidance and working code patterns for building concurrent async applications with tokio. ## Core Features & Use Cases - Runtime & Task Management: Guidance on choosing tokio multi-thread vs current-thread runtimes, spawning tasks with tokio::spawn, spawn_blocking, and JoinSet for structured concurrency. - Channel Communication Patterns: Covers mpsc, oneshot, broadcast, and watch channels with actor-style request-response designs and select! multiplexing. - Error Diagnosis: A lookup table mapping common compiler and runtime errors (Send violations, nested runtimes, deadlocks, channel backpressure) to concrete fixes. - Use Case: When building a high-concurrency HTTP service that needs graceful shutdown, use this Skill to implement a CancellationToken-coordinated shutdown with Semaphore-based rate limiting and async stream processing pipelines. ## Quick Start Ask the AI to write a tokio-based async worker that receives requests over an mpsc channel, responds via oneshot, and shuts down gracefully on Ctrl+C.

Frequently Asked Questions about rust-async-runtime

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I spawn concurrent async tasks in Rust with tokio?▼

Use tokio::spawn to submit a future to the runtime, which returns a JoinHandle you await for the result. For managing many tasks, use JoinSet to spawn multiple futures and collect results with join_next as they complete.

Which async runtime should I use: tokio, async-std, or smol?▼

Tokio is the recommended choice for production because it has the largest ecosystem and a work-stealing scheduler. async-std suits learning or small projects, while smol fits embedded or minimal-dependency scenarios.

Why does my async Rust code fail with 'future cannot be sent between threads safely'?▼

tokio::spawn requires the future to be Send, but your code holds a non-Send type like Rc or a MutexGuard across an await point. Replace Rc with Arc, shrink the guard's scope so it drops before await, or use spawn_local.

Can I use std::sync::Mutex inside async Rust code?▼

Yes, but only if the lock guard never lives across an .await point, otherwise you risk deadlock. When you must hold a lock across await, use tokio::sync::Mutex instead.

How do I avoid blocking the tokio runtime with synchronous code?▼

Never call blocking operations like std::thread::sleep or std::fs inside async contexts. Use tokio's async equivalents, or wrap unavoidable synchronous work in tokio::task::spawn_blocking to run it on a dedicated thread pool.

Does Rust support async fn in traits natively?▼

Rust Edition 2024 natively supports async fn in traits without the async-trait crate. For dyn-compatible trait objects, use the trait-variant crate or async-trait as a workaround.