Skip to main content

module

Attribute Macro module 

Source
#[module]
Expand description

Declares a Nidus module from a Rust struct.

#[module] is valid on named structs that represent application modules. It is metadata-generating behavior: the macro keeps the struct in place and implements Nidus module metadata so the runtime and CLI can inspect imports, providers, controllers, and exports without runtime reflection.

Basic syntax:

#[module(
    imports = [UsersModule],
    providers = [EmailService],
    controllers = [HealthController],
    exports = [EmailService],
)]
struct AppModule;

The generated module definition composes with Nidus::bootstrap::<AppModule>(), graph validation, CLI graph/check commands, and generated starter projects. Module entries are Rust types, not string names, so missing imports or renamed providers are caught by the compiler. Common errors include omitting brackets around metadata lists, placing the macro on enums or tuple structs, and exporting a provider that is not registered by the module or its imports.