Skip to main content

AppModule

Trait AppModule 

Source
pub trait AppModule:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn schema(&self) -> SchemaSet;
    fn init(&self, context: &mut ModuleContext);

    // Provided methods
    fn migrations(&self) -> Vec<Migration> { ... }
    fn migration_path(&self) -> Option<&'static str> { ... }
    fn sync_registry(&self) -> Option<Registry> { ... }
    fn schema_objects(&self) -> Vec<SchemaObjectState> { ... }
    fn subscribe(&self, _state: &AppState) { ... }
    fn start(&self, _state: &AppState) { ... }
    fn middleware(&self, router: Router, _state: &AppState) -> Router { ... }
    fn openapi(&self, _state: &AppState) -> Value { ... }
}

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn schema(&self) -> SchemaSet

Source

fn init(&self, context: &mut ModuleContext)

Provided Methods§

Source

fn migrations(&self) -> Vec<Migration>

Compiled migrations owned by this application, including portable project modules. Legacy project registries may still be passed to Management.

Source

fn migration_path(&self) -> Option<&'static str>

Writable source directory for makemigrations. None denotes a library application whose migration sources are not managed by this project.

Source

fn sync_registry(&self) -> Option<Registry>

Register server synchronization tables in the desired migration state. Several modules may expose their registries; shared server metadata tables are included once per database.

Source

fn schema_objects(&self) -> Vec<SchemaObjectState>

Triggers and views owned by this application. Their app field is assigned from Self::name while collecting migration state.

Source

fn subscribe(&self, _state: &AppState)

Source

fn start(&self, _state: &AppState)

Source

fn middleware(&self, router: Router, _state: &AppState) -> Router

Source

fn openapi(&self, _state: &AppState) -> Value

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§