Skip to main content

app

Attribute Macro app 

Source
#[app]
Expand description

Attach protocol-neutral application metadata to an impl block.

#[app] is consumed by all protocol macros on the same impl block (#[server], #[cli], #[http], #[program], etc.). It does not generate code itself — it passes metadata downstream via an internal #[__app_meta] helper attribute that the consuming macro removes.

§Fields

FieldDefaultEffect
nameinferred from struct name (kebab-case)App name used in config file path, CLI header, spec titles
descriptionnoneHuman-readable description for CLI --help, OpenAPI info, etc.
versionenv!("CARGO_PKG_VERSION")Version string; powers --version; false disables version entirely
homepagenoneURL used in OpenAPI info.contact.url, OpenRPC info, etc.

§Example

#[app(
    name = "myapp",
    description = "Does the thing",
    version = "2.1.0",
    homepage = "https://myapp.example.com",
)]
#[server]
impl MyApi {
    fn list_items(&self) -> Vec<Item> { ... }
}

All preset macros also accept these fields inline as a shorthand:

#[server(name = "myapp", description = "Does the thing")]
impl MyApi { ... }