standards-rust-async

Apply Rust async best practices for Tokio-based code.

2|Updated Apr 10, 2024
One-click install
npx skills add https://github.com/gdurandvadas/dotfiles --skill standards-rust-async
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: standards-rust-async
Source: https://github.com/gdurandvadas/dotfiles/tree/main/config/opencode/skills/standards-rust-async
Command: npx skills add https://github.com/gdurandvadas/dotfiles --skill standards-rust-async

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust developers often face difficulties writing correct and efficient asynchronous code in Tokio, leading to bugs, deadlocks, and maintenance challenges.

Core Features & Use Cases

  • Async/await patterns with Tokio and common primitives (tokio::sync::Mutex, channels, streams) to model concurrent workflows safely.
  • Task lifecycle guidance, cancellation patterns, and graceful shutdown strategies applicable across servers, CLIs, and libraries.
  • Guidance on proper synchronization primitive selection and robust error handling and tests for async Rust code.

Quick Start

Apply the Tokio-based standards to your Rust project to ensure non-blocking I/O, correct mutex usage, and robust error handling.

Frequently Asked Questions about standards-rust-async

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

FAQPage Schema
How do I implement graceful shutdown in Rust async Tokio applications?

Graceful shutdown in Rust async Tokio applications requires tracking task lifecycles and applying cancellation patterns to safely drain active streams. Use these standards to establish robust shutdown strategies across servers, CLIs, and libraries.

When should I use tokio::sync::Mutex instead of std::sync::Mutex in async Rust code?

You should use tokio::sync::Mutex in async Rust code when the guard needs to be held across await points to avoid blocking the executor. These standards guide proper synchronization primitive selection for shared state concurrency.

What are the best practices for avoiding blocking calls in Rust async Tokio tasks?

Avoiding blocking calls in Rust async Tokio tasks requires ensuring all I/O operations are non-blocking and using appropriate channels for concurrent workflows. Apply these standards to enforce non-blocking I/O and correct mutex usage across your project.

How do I manage shared state and streams safely in Rust async code?

Manage shared state and streams safely in Rust async code by using appropriate synchronization primitives and channel patterns to model concurrent workflows. These standards provide guidance on robust error handling and tests for async Rust code.

Does this Rust async standards guidance apply to both servers and CLI libraries?

Yes, this Rust async standards guidance applies to both servers and CLI libraries by addressing task lifecycle and cancellation patterns. Apply the Tokio-based standards across real-world Rust projects to ensure scalability and reliability.

What is the best way to handle task cancellation patterns in Rust async Tokio?

The best way to handle task cancellation patterns in Rust async Tokio is to implement robust error handling alongside graceful shutdown strategies. Use these standards to model task lifecycles safely and improve code reliability.