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) -> Self
pub fn new(id: String, domain: Domain) -> Self
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>,
) -> Self
pub fn with_traits( id: String, domain: Domain, traits: HashMap<String, String>, ) -> Self
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.