rust-async-await-module-patterns

Provides guidance on implementing Rust async/await module patterns with Tokio and FFI safety.

836|66|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill rust-async-await-module-patterns-kreuzberg-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-async-await-module-patterns
Source: https://github.com/kreuzberg-dev/html-to-markdown/tree/main/.codex/skills/rust-async-await-module-patterns
Command: npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill rust-async-await-module-patterns-kreuzberg-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides clear guidelines and best practices for structuring Rust code that utilizes asynchronous programming with async/await, ensuring robust and maintainable module patterns.

Core Features & Use Cases

  • Tokio Runtime Management: Demonstrates efficient sharing of a single Tokio runtime instance.
  • FFI Safety: Details how to ensure Send + Sync compliance for types exposed to Foreign Function Interfaces.
  • Module Organization: Offers a recommended directory structure for separating sync, async, and bridge logic.
  • Use Case: A developer building a high-performance Rust library that needs to interact with synchronous codebases like Python or Ruby can use these patterns to manage async operations safely and efficiently.

Quick Start

Consult the documentation for best practices on managing Rust async runtimes and FFI safety.

Frequently Asked Questions about rust-async-await-module-patterns

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

FAQPage Schema
How do I structure Rust async/await module patterns to prevent runtime conflicts?

You structure Rust async/await module patterns by separating sync, async, and bridge logic into a recommended directory structure, which prevents runtime conflicts and ensures code maintainability. This approach keeps asynchronous operations isolated and organized.

How do I ensure Send + Sync compliance for Rust types exposed through FFI?

To ensure Send + Sync compliance for Rust types exposed through FFI, you must follow specific safety guidelines that allow asynchronous types to safely cross foreign function interface boundaries. This Skill details those FFI safety practices to prevent data races.

What is the best way to share a single Tokio runtime instance across a Rust library?

The best way to share a single Tokio runtime instance is through efficient runtime management patterns that avoid creating multiple runtimes. This Skill demonstrates how to manage and share the Tokio runtime safely within high-performance Rust libraries.

Can I use Rust async/await patterns to interact with synchronous codebases like Python or Ruby?

Yes, you can use these Rust async/await patterns to interact with synchronous codebases like Python or Ruby. The module organization guidelines help manage asynchronous operations safely and efficiently when bridging sync and async environments.

What are common anti-patterns when structuring asynchronous Rust applications?

Common anti-patterns in asynchronous Rust applications include improper runtime sharing and unsafe FFI boundaries. This Skill identifies these anti-patterns and provides testing strategies to validate your async Rust application structure.