async-trait

Apply the #[async_trait] macro to enable async methods on Rust trait objects.

3|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/yankeeinlondon/rusty-biscuit --skill async-trait
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: async-trait
Source: https://github.com/yankeeinlondon/rusty-biscuit/tree/main/.claude/skills/async-trait
Command: npx skills add https://github.com/yankeeinlondon/rusty-biscuit --skill async-trait

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Using async functions in trait objects is not natively supported in stable Rust. This skill explains how the #[async_trait] macro enables object-safe async methods, including Send/Sync bounds and performance implications.

Core Features & Use Cases

  • Applies #[async_trait] to both trait definitions and implementations to enable async methods on trait objects.
  • Documents and compares dynamic dispatch approaches with and without boxing, including the trade-offs of Send vs non-Send variants.
  • Provides practical usage patterns for registries, plugins, and dependency-injection scenarios in Rust.

Quick Start

Annotate a trait and its impl with #[async_trait] and start calling async methods on trait objects.

Frequently Asked Questions about async-trait

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

FAQPage Schema
How do I use async functions in Rust trait objects?

Using async functions in trait objects requires the #[async_trait] macro applied to both trait definitions and implementations, which makes async methods object-safe for dynamic dispatch across plugin systems and dependency injection patterns.

Why does Rust not natively support async functions in traits?

Stable Rust lacks native async trait object support because async methods return compiler-inferred futures. The #[async_trait] macro resolves this by boxing the returned future and applying default Send + Sync bounds for safe dynamic dispatch.

What is the best way to handle Send bounds for async trait objects?

Handling Send bounds for async trait objects is managed by the #[async_trait] macro, which enforces default Send + Sync bounds on futures while supporting an optional !Send variant for single-threaded execution contexts.

What are the performance implications of using async traits with dynamic dispatch?

Performance implications of async traits with dynamic dispatch include boxing overhead for returned futures and vtable lookup costs. The macro documents expansion details and compares dispatch approaches to help evaluate these trade-offs.

Can I use async traits for plugin registries and dependency injection in Rust?

Async traits are fully usable for plugin registries and dependency injection in Rust. The #[async_trait] macro provides practical usage patterns specifically designed for registries, plugins, and dependency injection requiring dynamic dispatch of async interfaces.

When should I not use the async-trait macro?

Avoid the async-trait macro when boxing overhead from dynamic dispatch is unacceptable for your performance requirements, or when static dispatch via generic async functions suffices without needing object-safe trait objects.