Attribute Macro rocket::async_trait
source · #[async_trait]
Expand description
Retrofits support for async fn
in trait impls and declarations.
Any trait declaration or trait impl
decorated with #[async_trait]
is
retrofitted with support for async fn
s:
#[async_trait]
trait MyAsyncTrait {
async fn do_async_work();
}
#[async_trait]
impl MyAsyncTrait for () {
async fn do_async_work() { /* .. */ }
}
All impl
s for a trait declared with #[async_trait]
must themselves be
decorated with #[async_trait]
. Many of Rocket’s traits, such as
FromRequest
and
Fairing
are async
. As such, implementations
of said traits must be decorated with #[async_trait]
. See the individual
trait docs for trait-specific details.
For more details on #[async_trait]
, see async_trait
.