moirai-async-macros 0.7.0

Proc-macros for moirai-async runtime
Documentation

moirai-async-macros

crates.io docs.rs

The #[main] attribute macro for the Moirai async runtime.

Rust's entry point cannot itself be async, so something has to build a runtime and block on the future. This crate is that shim, keeping executor construction out of user code: the annotated function is rewritten into a synchronous main that builds an AsyncExecutor with its defaults and blocks on the original body, preserving the function's attributes and visibility.

The macro is re-exported by moirai-async; depend on that crate rather than on this one directly.

[dependencies]
moirai-async = "0.5"
#[moirai_async::main]
async fn main() {
    println!("running on the Moirai async executor");
}

The attribute takes no arguments. A caller needing a configured executor should build one directly and call block_on instead. The generated main panics if the executor cannot be created — it runs before any user code, so there is no state to unwind.

Full documentation: https://docs.rs/moirai-async-macros

License

Licensed under either of Apache-2.0 or MIT at your option.