Module

Trait Module 

Source
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>>;

    // Provided method
    fn version(&self) -> &str { ... }
}
Expand description

Trait for a microservice module

Required Methods§

Source

fn name(&self) -> &str

Unique module name

Source

fn entity_types(&self) -> Vec<&str>

List of entity types managed by this module

Load links configuration

Source

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.

Source

fn get_entity_fetcher( &self, entity_type: &str, ) -> Option<Arc<dyn EntityFetcher>>

Get an entity fetcher for a specific entity type

This allows the framework to dynamically load entities when enriching links.

§Arguments
  • entity_type - The type of entity (e.g., “order”, “invoice”)
§Returns

An EntityFetcher implementation, or None if the entity type is not managed by this module

Provided Methods§

Source

fn version(&self) -> &str

Module version

Implementors§