pub trait Module: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn entity_types(&self) -> Vec<&str>;
fn links_config(&self) -> Result<LinksConfig>;
fn register_entities(&self, registry: &mut EntityRegistry);
fn get_entity_fetcher(
&self,
entity_type: &str,
) -> Option<Arc<dyn EntityFetcher>>;
fn get_entity_creator(
&self,
entity_type: &str,
) -> Option<Arc<dyn EntityCreator>>;
// Provided method
fn version(&self) -> &str { ... }
}Expand description
Trait for a microservice module
Required Methods§
Sourcefn entity_types(&self) -> Vec<&str>
fn entity_types(&self) -> Vec<&str>
List of entity types managed by this module
Sourcefn links_config(&self) -> Result<LinksConfig>
fn links_config(&self) -> Result<LinksConfig>
Load links configuration
Sourcefn register_entities(&self, registry: &mut EntityRegistry)
fn register_entities(&self, registry: &mut EntityRegistry)
Register entities with the entity registry
This method should register all entity descriptors for the module. Each entity descriptor provides the CRUD routes for that entity.
Sourcefn get_entity_fetcher(
&self,
entity_type: &str,
) -> Option<Arc<dyn EntityFetcher>>
fn get_entity_fetcher( &self, entity_type: &str, ) -> Option<Arc<dyn EntityFetcher>>
Sourcefn get_entity_creator(
&self,
entity_type: &str,
) -> Option<Arc<dyn EntityCreator>>
fn get_entity_creator( &self, entity_type: &str, ) -> Option<Arc<dyn EntityCreator>>
Get an entity creator for a specific entity type
This allows the framework to create new entities dynamically when creating linked entities.
§Arguments
entity_type- The type of entity (e.g., “order”, “invoice”)
§Returns
An EntityCreator implementation, or None if the entity type is not managed by this module