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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EntityRegistry
impl Debug for EntityRegistry
Source§impl Default for EntityRegistry
impl Default for EntityRegistry
Source§fn default() -> EntityRegistry
fn default() -> EntityRegistry
Source§impl<'de> Deserialize<'de> for EntityRegistry
impl<'de> Deserialize<'de> for EntityRegistry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for EntityRegistry
impl RefUnwindSafe for EntityRegistry
impl Send for EntityRegistry
impl Sync for EntityRegistry
impl Unpin for EntityRegistry
impl UnsafeUnpin for EntityRegistry
impl UnwindSafe for EntityRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.