ConsistencyStore

Struct ConsistencyStore 

Source
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

Source

pub fn new() -> Self

Create a new consistency store

Source

pub fn with_default_domain(default_domain: Domain) -> Self

Create a consistency store with a default domain

Source

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

Source

pub fn with_persona_graph(persona_graph: Arc<PersonaGraph>) -> Self

Create a consistency store with a persona graph

Source

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.

Source

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.

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).

Source

pub fn persona_graph(&self) -> &Arc<PersonaGraph>

Get the persona graph

Source

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.

Source

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.

Source

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 ID
  • field_type - Type of field to generate
  • domain - 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 with
  • real_data - Optional real/upstream data to blend with
Source

pub fn persona_registry(&self) -> &Arc<PersonaRegistry>

Get the persona registry

Source

pub fn set_default_domain(&mut self, domain: Option<Domain>)

Set the default domain

Source

pub fn default_domain(&self) -> Option<Domain>

Get the default domain

Source

pub fn clear(&self)

Clear all personas (useful for testing or reset)

Source

pub fn persona_count(&self) -> usize

Get the number of registered personas

Trait Implementations§

Source§

impl Debug for ConsistencyStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConsistencyStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Fake for T

Source§

fn fake<U>(&self) -> U
where Self: FakeBase<U>,

Source§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> U
where R: Rng + ?Sized, Self: FakeBase<U>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ParallelSend for T