pub trait Module:
Send
+ Sync
+ 'static {
// Required method
fn id(&self) -> ModuleId;
// Provided methods
fn migrations(&self) -> MigrationSet { ... }
fn requires(&self) -> &'static [ModuleId] { ... }
fn requires_db_capabilities(&self) -> &'static [Capability] { ... }
fn optional_db_capabilities(&self) -> &'static [Capability] { ... }
fn register(&self, registry: &mut Registry) { ... }
fn boot<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cx: &'life1 BootCx<'life2>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn admin_base(&self) -> Option<&'static str> { ... }
fn catalogs(&self) -> &'static [(&'static str, &'static str)] { ... }
}Expand description
A registerable unit: a framework crate or an application feature/plugin.
Required Methods§
Sourcefn id(&self) -> ModuleId
fn id(&self) -> ModuleId
Stable identity, a lowercase vendor.package code. Namespaces this
module’s applied-migration history and is the target of other modules’
requires. Its string must equal the module_id of
the set returned by migrations.
Provided Methods§
Sourcefn migrations(&self) -> MigrationSet
fn migrations(&self) -> MigrationSet
This module’s migrations, in apply order. Defaults to none, for a code-only module.
Sourcefn requires(&self) -> &'static [ModuleId]
fn requires(&self) -> &'static [ModuleId]
Ids of modules whose migrations and registration must run before this module’s, so cross-module foreign keys and contributions resolve. Defaults to none.
Sourcefn requires_db_capabilities(&self) -> &'static [Capability]
fn requires_db_capabilities(&self) -> &'static [Capability]
Database capabilities this module cannot work without. The application refuses to boot if one is unavailable, with a clear error naming the module and capability, instead of failing deep inside a migration.
Sourcefn optional_db_capabilities(&self) -> &'static [Capability]
fn optional_db_capabilities(&self) -> &'static [Capability]
Database capabilities this module uses when present and does without when
absent. Query the boot-time CapabilitySet
to gate the enhanced path (for example trigram fuzzy search).
Sourcefn boot<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cx: &'life1 BootCx<'life2>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn boot<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cx: &'life1 BootCx<'life2>,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Runs once at boot, after every module’s migrations have applied and every module has registered, before anything is served: the place for a sweep, a seed, or a check that needs the database. An error aborts the boot; for a plugin it quarantines the plugin instead. Default: nothing.
Sourcefn admin_base(&self) -> Option<&'static str>
fn admin_base(&self) -> Option<&'static str>
Where this module’s admin screens mount, relative to the admin root.
None (the default) namespaces them under the module’s identity, so
rainmill.location contributing /nodes serves /rainmill/location/nodes
and two modules cannot collide by accident. Declaring a base takes that
path instead, which is a claim: a clash with another module aborts boot.
A deployment can override either through backend.paths.
Sourcefn catalogs(&self) -> &'static [(&'static str, &'static str)]
fn catalogs(&self) -> &'static [(&'static str, &'static str)]
This module’s UI-string catalogs, as (locale, po_text) pairs, each an
include_str!’d gettext PO baked into the binary. English needs none (its
source string is the key); other locales ship a PO. The boot loader merges
them into the shared catalog store. Default: none.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".