pub struct PersonaProfile {
pub id: String,
pub domain: Domain,
pub traits: HashMap<String, String>,
pub seed: u64,
pub backstory: Option<String>,
pub relationships: HashMap<String, Vec<String>>,
pub metadata: HashMap<String, Value>,
pub lifecycle: Option<PersonaLifecycle>,
}Expand description
Persona profile defining a consistent data personality
Fields§
§id: StringUnique identifier for this persona (e.g., user_id, device_id, transaction_id)
domain: DomainBusiness domain this persona belongs to
traits: HashMap<String, String>Trait name to value mappings (e.g., “spending_level” → “high”, “account_type” → “premium”)
seed: u64Deterministic seed derived from persona ID and domain for consistency
backstory: Option<String>Narrative backstory explaining persona behavior and characteristics
relationships: HashMap<String, Vec<String>>Relationships to other personas Keys: relationship types (“owns_devices”, “belongs_to_org”, “has_users”) Values: List of related persona IDs
metadata: HashMap<String, Value>Additional persona-specific metadata
lifecycle: Option<PersonaLifecycle>Optional lifecycle state management
Implementations§
Source§impl PersonaProfile
impl PersonaProfile
Sourcepub fn new(id: String, domain: Domain) -> PersonaProfile
pub fn new(id: String, domain: Domain) -> PersonaProfile
Create a new persona profile
The seed is deterministically derived from the persona ID and domain, ensuring the same ID and domain always produce the same seed.
Sourcepub fn with_traits(
id: String,
domain: Domain,
traits: HashMap<String, String>,
) -> PersonaProfile
pub fn with_traits( id: String, domain: Domain, traits: HashMap<String, String>, ) -> PersonaProfile
Create a persona with initial traits
Sourcepub fn set_lifecycle(&mut self, lifecycle: PersonaLifecycle)
pub fn set_lifecycle(&mut self, lifecycle: PersonaLifecycle)
Set the persona’s lifecycle
Sourcepub fn get_lifecycle(&self) -> Option<&PersonaLifecycle>
pub fn get_lifecycle(&self) -> Option<&PersonaLifecycle>
Get the persona’s lifecycle
Sourcepub fn get_lifecycle_mut(&mut self) -> Option<&mut PersonaLifecycle>
pub fn get_lifecycle_mut(&mut self) -> Option<&mut PersonaLifecycle>
Get mutable reference to lifecycle
Sourcepub fn update_lifecycle_state(&mut self, current_time: DateTime<Utc>)
pub fn update_lifecycle_state(&mut self, current_time: DateTime<Utc>)
Update lifecycle state based on virtual clock time
Checks if any transitions should occur based on elapsed time and conditions.
Sourcepub fn set_metadata(&mut self, key: String, value: Value)
pub fn set_metadata(&mut self, key: String, value: Value)
Add metadata
Sourcepub fn get_metadata(&self, key: &str) -> Option<&Value>
pub fn get_metadata(&self, key: &str) -> Option<&Value>
Get metadata
Sourcepub fn set_backstory(&mut self, backstory: String)
pub fn set_backstory(&mut self, backstory: String)
Set the persona’s backstory
The backstory provides narrative context that explains the persona’s behavior and characteristics, enabling coherent data generation.
Sourcepub fn get_backstory(&self) -> Option<&String>
pub fn get_backstory(&self) -> Option<&String>
Get the persona’s backstory
Sourcepub fn has_backstory(&self) -> bool
pub fn has_backstory(&self) -> bool
Check if the persona has a backstory
Sourcepub fn add_relationship(
&mut self,
relationship_type: String,
related_persona_id: String,
)
pub fn add_relationship( &mut self, relationship_type: String, related_persona_id: String, )
Add a relationship to another persona
§Arguments
relationship_type- Type of relationship (e.g., “owns_devices”, “belongs_to_org”, “has_users”)related_persona_id- ID of the related persona
Sourcepub fn get_relationships(&self, relationship_type: &str) -> Option<&Vec<String>>
pub fn get_relationships(&self, relationship_type: &str) -> Option<&Vec<String>>
Get all relationships of a specific type
Returns a list of persona IDs that have the specified relationship type.
Get all related personas for a specific relationship type
Returns a cloned vector of persona IDs, or an empty vector if no relationships exist.
Sourcepub fn get_relationship_types(&self) -> Vec<String>
pub fn get_relationship_types(&self) -> Vec<String>
Get all relationship types for this persona
Sourcepub fn remove_relationship(
&mut self,
relationship_type: &str,
related_persona_id: &str,
) -> bool
pub fn remove_relationship( &mut self, relationship_type: &str, related_persona_id: &str, ) -> bool
Remove a specific relationship
Removes the specified persona ID from the relationship type’s list. Returns true if the relationship was found and removed.
Trait Implementations§
Source§impl Clone for PersonaProfile
impl Clone for PersonaProfile
Source§fn clone(&self) -> PersonaProfile
fn clone(&self) -> PersonaProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PersonaProfile
impl Debug for PersonaProfile
Source§impl<'de> Deserialize<'de> for PersonaProfile
impl<'de> Deserialize<'de> for PersonaProfile
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PersonaProfile, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PersonaProfile, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for PersonaProfile
impl Serialize for PersonaProfile
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for PersonaProfile
impl RefUnwindSafe for PersonaProfile
impl Send for PersonaProfile
impl Sync for PersonaProfile
impl Unpin for PersonaProfile
impl UnwindSafe for PersonaProfile
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more