Attribute Macro mpris_server::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] or #[async_trait(?Send)] is retrofitted with support for async fns:

§Examples

use mpris_server::{async_trait, LocalRootInterface, RootInterface};
use zbus::fdo;

struct MyPlayer;

#[async_trait]
impl RootInterface for MyPlayer {
    async fn identity(&self) -> fdo::Result<String> {
        Ok("MyPlayer".into())
    }

    // Other methods...
}

struct MyLocalPlayer;

#[async_trait(?Send)]
impl LocalRootInterface for MyLocalPlayer {
    async fn identity(&self) -> fdo::Result<String> {
        Ok("MyLocalPlayer".into())
    }

    // Other methods...
}