whatisgithub

What is async-trait?

dtolnay/async-trait — explained in plain English

Analysis updated 2026-07-17 · repo last pushed 2026-03-24

2,157RustAudience · developerComplexity · 2/5MaintainedSetup · easy

In one sentence

async-trait is a Rust macro that lets you write async methods inside traits, something Rust doesn't support natively, so trait objects can hold different types that each run async code.

Mindmap

mindmap
  root((repo))
    What it does
      Async trait methods
      Macro based
      Dynamic dispatch
    Tech stack
      Rust
      Procedural macros
    Use cases
      Plugin systems
      Shared interfaces
      Trait objects
    Audience
      Rust developers
    Caveats
      Send bounds
      Explicit lifetimes

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add async methods to a Rust trait by marking it with #[async_trait], without hand-writing future plumbing.

USE CASE 2

Build a plugin-style system where different types implement a shared trait with an async run() method.

USE CASE 3

Use dynamic dispatch with async trait methods, like storing different ad types or handlers behind one interface.

USE CASE 4

Opt out of Send bounds with #[async_trait(?Send)] when your async trait methods don't need to cross threads.

What is it built with?

Rust

How does it compare?

dtolnay/async-traitb-nnett/gooseorhun/ratty
Stars2,1572,1762,082
LanguageRustRustRust
Last pushed2026-03-24
MaintenanceMaintained
Setup difficultyeasyhardmoderate
Complexity2/54/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Copy-paste prompts

Prompt 1
Show me how to add the #[async_trait] macro to a Rust trait so I can define an async method inside it.
Prompt 2
I have a Rust trait with different implementations that each need an async run() method. Show me how async-trait makes that work with dynamic dispatch.
Prompt 3
Explain what #[async_trait(?Send)] does and when I should use it instead of the default macro behavior.
Prompt 4
Write a Rust example using async-trait where a trait has a default implementation for one async method and a required implementation for another.
Prompt 5
How does the async-trait macro convert my async method into something compatible with Rust's trait objects under the hood?

Frequently asked questions

What is async-trait?

async-trait is a Rust macro that lets you write async methods inside traits, something Rust doesn't support natively, so trait objects can hold different types that each run async code.

What language is async-trait written in?

Mainly Rust. The stack also includes Rust.

Is async-trait actively maintained?

Maintained — commit in last 6 months (last push 2026-03-24).

How hard is async-trait to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is async-trait for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.