pub struct ConsistencyStore { /* private fields */ }Expand description
Consistency store for maintaining entity ID to persona mappings
Provides thread-safe access to persona-based data generation with in-memory caching and optional persistence capabilities. Supports cross-entity type consistency where the same base ID can have different personas for different entity types (user, device, organization).
Implementations§
Source§impl ConsistencyStore
impl ConsistencyStore
Sourcepub fn with_default_domain(default_domain: Domain) -> Self
pub fn with_default_domain(default_domain: Domain) -> Self
Create a consistency store with a default domain
Sourcepub fn with_registry_and_domain(
persona_registry: Arc<PersonaRegistry>,
default_domain: Option<Domain>,
) -> Self
pub fn with_registry_and_domain( persona_registry: Arc<PersonaRegistry>, default_domain: Option<Domain>, ) -> Self
Create a consistency store with a persona registry and default domain
Sourcepub fn with_persona_graph(persona_graph: Arc<PersonaGraph>) -> Self
pub fn with_persona_graph(persona_graph: Arc<PersonaGraph>) -> Self
Create a consistency store with a persona graph
Sourcepub fn get_entity_persona(
&self,
entity_id: &str,
domain: Option<Domain>,
) -> PersonaProfile
pub fn get_entity_persona( &self, entity_id: &str, domain: Option<Domain>, ) -> PersonaProfile
Get or create a persona for an entity
If a persona for this entity ID already exists, returns it. Otherwise, creates a new persona with the specified domain.
Sourcepub fn get_or_create_persona_by_type(
&self,
entity_id: &str,
entity_type: EntityType,
domain: Option<Domain>,
) -> PersonaProfile
pub fn get_or_create_persona_by_type( &self, entity_id: &str, entity_type: EntityType, domain: Option<Domain>, ) -> PersonaProfile
Get or create a persona for an entity with a specific type
Creates a persona keyed by both entity ID and entity type, allowing the same base ID to have different personas for different types (e.g., “user123” as a user vs “user123” as a device owner).
The persona ID is constructed as “{entity_type}:{entity_id}” to ensure uniqueness. Also automatically links personas in the persona graph.
Sourcepub fn link_personas(
&self,
from_entity_id: &str,
from_entity_type: &str,
to_entity_id: &str,
to_entity_type: &str,
)
pub fn link_personas( &self, from_entity_id: &str, from_entity_type: &str, to_entity_id: &str, to_entity_type: &str, )
Link two personas in the graph based on their entity types
This is a convenience method for establishing relationships between personas of different entity types (e.g., user -> order, order -> payment).
Sourcepub fn persona_graph(&self) -> &Arc<PersonaGraph>
pub fn persona_graph(&self) -> &Arc<PersonaGraph>
Get the persona graph
Sourcepub fn get_personas_for_base_id(
&self,
base_id: &str,
domain: Option<Domain>,
) -> Vec<PersonaProfile>
pub fn get_personas_for_base_id( &self, base_id: &str, domain: Option<Domain>, ) -> Vec<PersonaProfile>
Get all personas for a base entity ID across different types
Returns personas for all entity types associated with the base ID.
Sourcepub fn generate_consistent_value(
&self,
entity_id: &str,
field_type: &str,
domain: Option<Domain>,
) -> Result<Value>
pub fn generate_consistent_value( &self, entity_id: &str, field_type: &str, domain: Option<Domain>, ) -> Result<Value>
Generate a consistent value for an entity
Uses the entity’s persona to generate a value that will be consistent across multiple calls for the same entity ID and field type.
Sourcepub fn generate_consistent_value_with_reality(
&self,
entity_id: &str,
field_type: &str,
domain: Option<Domain>,
reality_ratio: f64,
recorded_data: Option<&Value>,
real_data: Option<&Value>,
) -> Result<Value>
pub fn generate_consistent_value_with_reality( &self, entity_id: &str, field_type: &str, domain: Option<Domain>, reality_ratio: f64, recorded_data: Option<&Value>, real_data: Option<&Value>, ) -> Result<Value>
Generate a consistent value for an entity with reality awareness
Uses the entity’s persona to generate a value that will be consistent across multiple calls, with reality continuum blending applied.
§Arguments
entity_id- Entity IDfield_type- Type of field to generatedomain- Optional domain (uses default if not provided)reality_ratio- Reality continuum ratio (0.0 = mock, 1.0 = real)recorded_data- Optional recorded/snapshot data to blend withreal_data- Optional real/upstream data to blend with
Sourcepub fn persona_registry(&self) -> &Arc<PersonaRegistry>
pub fn persona_registry(&self) -> &Arc<PersonaRegistry>
Get the persona registry
Sourcepub fn set_default_domain(&mut self, domain: Option<Domain>)
pub fn set_default_domain(&mut self, domain: Option<Domain>)
Set the default domain
Sourcepub fn default_domain(&self) -> Option<Domain>
pub fn default_domain(&self) -> Option<Domain>
Get the default domain
Sourcepub fn persona_count(&self) -> usize
pub fn persona_count(&self) -> usize
Get the number of registered personas