pub trait Module:
Send
+ Sync
+ 'static {
// Required methods
fn metadata(&self) -> ModuleMetadata;
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn init<'life0, 'async_trait>(
&'life0 mut self,
_bus: MessageBus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait implemented by all native, in-process modules.
Methods are async because most kernel work flows through Tokio and many
modules need to await I/O during start/stop. Implementors should not
block the runtime in these hooks.
Required Methods§
Sourcefn metadata(&self) -> ModuleMetadata
fn metadata(&self) -> ModuleMetadata
Static module metadata.
Provided Methods§
Sourcefn init<'life0, 'async_trait>(
&'life0 mut self,
_bus: MessageBus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 mut self,
_bus: MessageBus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize the module. Called once, before start.
The bus is provided so the module can subscribe to events or publish
initial state. The default implementation is a no-op.