pub struct EntityRegistry { /* private fields */ }Expand description
Central registry for all master data entities.
Ensures referential integrity by tracking entity existence and validity over time. All transaction generators should check this registry before using any master data reference.
Implementations§
Source§impl EntityRegistry
impl EntityRegistry
Sourcepub fn register(&mut self, record: EntityRecord)
pub fn register(&mut self, record: EntityRecord)
Register a new entity.
Sourcepub fn get(&self, entity_id: &EntityId) -> Option<&EntityRecord>
pub fn get(&self, entity_id: &EntityId) -> Option<&EntityRecord>
Get an entity by ID.
Sourcepub fn get_mut(&mut self, entity_id: &EntityId) -> Option<&mut EntityRecord>
pub fn get_mut(&mut self, entity_id: &EntityId) -> Option<&mut EntityRecord>
Get a mutable reference to an entity.
Sourcepub fn is_valid(&self, entity_id: &EntityId, date: NaiveDate) -> bool
pub fn is_valid(&self, entity_id: &EntityId, date: NaiveDate) -> bool
Check if an entity exists and is valid on a given date.
Sourcepub fn can_transact(&self, entity_id: &EntityId, date: NaiveDate) -> bool
pub fn can_transact(&self, entity_id: &EntityId, date: NaiveDate) -> bool
Check if an entity can be used in transactions on a given date.
Sourcepub fn get_by_type(&self, entity_type: EntityType) -> Vec<&EntityRecord>
pub fn get_by_type(&self, entity_type: EntityType) -> Vec<&EntityRecord>
Get all entities of a given type.
Sourcepub fn get_valid_by_type(
&self,
entity_type: EntityType,
date: NaiveDate,
) -> Vec<&EntityRecord>
pub fn get_valid_by_type( &self, entity_type: EntityType, date: NaiveDate, ) -> Vec<&EntityRecord>
Get all entities of a given type that are valid on a date.
Sourcepub fn get_by_company(&self, company_code: &str) -> Vec<&EntityRecord>
pub fn get_by_company(&self, company_code: &str) -> Vec<&EntityRecord>
Get all entities for a company code.
Sourcepub fn get_ids_by_type(&self, entity_type: EntityType) -> Vec<&EntityId>
pub fn get_ids_by_type(&self, entity_type: EntityType) -> Vec<&EntityId>
Get all entity IDs of a given type.
Sourcepub fn count_by_type(&self, entity_type: EntityType) -> usize
pub fn count_by_type(&self, entity_type: EntityType) -> usize
Get count of entities by type.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Get total count of all entities.
Sourcepub fn update_status(
&mut self,
entity_id: &EntityId,
new_status: EntityStatus,
date: NaiveDate,
) -> bool
pub fn update_status( &mut self, entity_id: &EntityId, new_status: EntityStatus, date: NaiveDate, ) -> bool
Update entity status.
Sourcepub fn block(&mut self, entity_id: &EntityId, date: NaiveDate) -> bool
pub fn block(&mut self, entity_id: &EntityId, date: NaiveDate) -> bool
Block an entity for new transactions.
Sourcepub fn get_events_on(&self, date: NaiveDate) -> &[EntityEvent]
pub fn get_events_on(&self, date: NaiveDate) -> &[EntityEvent]
Get events that occurred on a specific date.
Sourcepub fn get_events_in_range(
&self,
from: NaiveDate,
to: NaiveDate,
) -> Vec<&EntityEvent>
pub fn get_events_in_range( &self, from: NaiveDate, to: NaiveDate, ) -> Vec<&EntityEvent>
Get events in a date range.
Sourcepub fn timeline_dates(&self) -> impl Iterator<Item = &NaiveDate>
pub fn timeline_dates(&self) -> impl Iterator<Item = &NaiveDate>
Get the timeline entry dates.
Sourcepub fn validate_reference(
&self,
entity_id: &EntityId,
transaction_date: NaiveDate,
) -> Result<(), String>
pub fn validate_reference( &self, entity_id: &EntityId, transaction_date: NaiveDate, ) -> Result<(), String>
Validate that an entity reference can be used on a transaction date. Returns an error message if invalid.
Sourcepub fn rebuild_indices(&mut self)
pub fn rebuild_indices(&mut self)
Rebuild all indices (call after deserialization).
Sourcepub fn register_entity(&mut self, record: EntityRecord)
pub fn register_entity(&mut self, record: EntityRecord)
Alias for register - registers a new entity.
Sourcepub fn record_event(&mut self, event: EntityEvent)
pub fn record_event(&mut self, event: EntityEvent)
Record an event for an entity.
Sourcepub fn is_valid_on(&self, entity_id: &EntityId, date: NaiveDate) -> bool
pub fn is_valid_on(&self, entity_id: &EntityId, date: NaiveDate) -> bool
Check if an entity is valid on a given date.
Alias for is_valid.
Trait Implementations§
Source§impl Clone for EntityRegistry
impl Clone for EntityRegistry
Source§fn clone(&self) -> EntityRegistry
fn clone(&self) -> EntityRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more