Skip to main content

Crate churust_macros

Crate churust_macros 

Source
Expand description

Procedural macros for the Churust web framework.

This crate exposes a single attribute macro, main, which turns an async fn main() into a synchronous entry point backed by a multi-threaded Tokio runtime. You should not depend on this crate directly; instead use the top-level churust crate and write #[churust::main].

§Quick start

In your application’s main.rs, after adding churust as a dependency:

#[churust::main]
async fn main() -> std::io::Result<()> {
    // Churust::server()…start().await goes here.
    Ok(())
}

The examples in this crate are illustrations rather than doctests: the generated code names ::churust, which cannot resolve from inside churust-macros because churust depends on this crate and not the reverse. Executable coverage lives in churust/tests/macro_main.rs.

The attribute strips the async modifier and injects a Tokio runtime so that the Rust compiler sees an ordinary synchronous fn main(). This mirrors the ergonomics of #[tokio::main] while keeping the framework’s entry-point convention explicit and framework-branded.

§When to use this crate directly

Almost never. The re-export via churust::main (or churust::prelude::*) is the intended consumption path. The only reason to take a direct dependency on churust-macros is if you are building a crate that wraps or extends Churust’s attribute macros at a low level.

Attribute Macros§

main
Turns async fn main() into a synchronous entry point that runs on a multi-threaded Tokio runtime.