Skip to main content

Module

Trait Module 

Source
pub trait Module:
    Send
    + Sync
    + 'static {
    // Required method
    fn register(&self, m: &mut ModuleBuilder);

    // Provided methods
    fn id(&self) -> ModuleId { ... }
    fn name(&self) -> &'static str { ... }
    fn is_configured(&self) -> bool { ... }
}
Expand description

A unit of an app: it registers providers, exports, imports, contributions, lifecycle hooks and commands through a ModuleBuilder.

register is called once per ModuleId per boot. A configured instance (for_root(...), is_configured returns true) wins over plain imports of the same module type.

Required Methods§

Source

fn register(&self, m: &mut ModuleBuilder)

Registers everything the module contributes.

Provided Methods§

Source

fn id(&self) -> ModuleId

The module identity. for_root wrappers override this to return the id of the module type they configure.

Source

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

The readable module name used in errors and reports.

Source

fn is_configured(&self) -> bool

for_root(...) values return true; at most one configured instance per id.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<M: 'static, O: Clone + Send + Sync + 'static> Module for ConfiguredModule<M, O>