pub trait Module: 'static + Sized {
type Config: 'static + Sized + Clone + PartialEq + Debug = ();
type Dependencies: Dependencies = ();
// Required method
fn new(config: Self::Config, deps: Self::Dependencies) -> Result<Self>;
// Provided method
fn intialize(_handle: Handle<Self>) -> Result<()> { ... }
}Expand description
A module that is part of an app.
Provided Associated Types§
Sourcetype Config: 'static + Sized + Clone + PartialEq + Debug = ()
type Config: 'static + Sized + Clone + PartialEq + Debug = ()
Some initial data that configures the module. Provided by the User when adding a module to an app.
Sourcetype Dependencies: Dependencies = ()
type Dependencies: Dependencies = ()
Other modules that are expected to be part of the app. Provided automatically during app setup, where the program resolves which dependencies each module has.
Required Methods§
Sourcefn new(config: Self::Config, deps: Self::Dependencies) -> Result<Self>
fn new(config: Self::Config, deps: Self::Dependencies) -> Result<Self>
creates this module
Provided Methods§
Sourcefn intialize(_handle: Handle<Self>) -> Result<()>
fn intialize(_handle: Handle<Self>) -> Result<()>
Is run once, after all modules have been initialized.
This function is optional, it is given a handle to the module itself.
other modules can be accessed if you cache the handles to them in the new() function.
E.g. the LineRenderer could register its own handle (HandleHandle<Renderer> was part of the Self::Dependencies and cached in the new function.
E.g. LineRenderer could have a field renderer: Handle<Renderer> that is populated in new.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.