Skip to main content

injectable

Attribute Macro injectable 

Source
#[injectable]
Expand description

Attribute macro to auto-register a concrete type as a singleton

This macro automatically:

  1. Derives Default and Clone for the struct
  2. Registers it as a singleton in the App container at startup

§Example

use ferro::injectable;

#[injectable]
pub struct AppState {
    pub counter: u32,
}

// Automatically registered at startup
// Resolve via:
let state: AppState = App::get().unwrap();