sync

Attribute Macro sync 

#[sync]
Available on crate feature macros only.
Expand description

Mark an async method as internally synchronous.

The trait declaration must have been decorated with dyn_trait, and the trait method declaration with try_sync.

ยงExamples

#[dyn_utils::dyn_trait]
trait Callback {
    #[dyn_trait(try_sync)]
    fn call(&self, arg: &str) -> impl Future<Output = ()> + Send;
}

struct HelloCallback;
impl Callback for HelloCallback {
    #[dyn_utils::sync]
    async fn call(&self, arg: &str) {
        println!("Hello {arg}!");
    }
}