pub struct PersonaRegistry { /* private fields */ }Expand description
Registry for managing persona profiles
Provides thread-safe access to persona profiles with in-memory storage and optional persistence capabilities.
Implementations§
Source§impl PersonaRegistry
impl PersonaRegistry
Sourcepub fn with_default_traits(default_traits: HashMap<String, String>) -> Self
pub fn with_default_traits(default_traits: HashMap<String, String>) -> Self
Create a registry with default traits for new personas
Sourcepub fn graph(&self) -> Arc<PersonaGraph>
pub fn graph(&self) -> Arc<PersonaGraph>
Get the persona graph
Sourcepub fn get_or_create_persona(
&self,
id: String,
domain: Domain,
) -> PersonaProfile
pub fn get_or_create_persona( &self, id: String, domain: Domain, ) -> PersonaProfile
Get or create a persona profile
If a persona with the given ID exists, returns it. Otherwise, creates a new persona with the specified domain and applies default traits.
Sourcepub fn get_persona(&self, id: &str) -> Option<PersonaProfile>
pub fn get_persona(&self, id: &str) -> Option<PersonaProfile>
Get a persona by ID
Sourcepub fn update_persona(
&self,
id: &str,
traits: HashMap<String, String>,
) -> Result<()>
pub fn update_persona( &self, id: &str, traits: HashMap<String, String>, ) -> Result<()>
Update persona traits
Sourcepub fn update_persona_backstory(
&self,
id: &str,
backstory: String,
) -> Result<()>
pub fn update_persona_backstory( &self, id: &str, backstory: String, ) -> Result<()>
Update persona backstory
Sets or updates the backstory for an existing persona.
Sourcepub fn update_persona_full(
&self,
id: &str,
traits: Option<HashMap<String, String>>,
backstory: Option<String>,
relationships: Option<HashMap<String, Vec<String>>>,
) -> Result<()>
pub fn update_persona_full( &self, id: &str, traits: Option<HashMap<String, String>>, backstory: Option<String>, relationships: Option<HashMap<String, Vec<String>>>, ) -> Result<()>
Update persona with full profile data
Updates traits, backstory, and relationships for an existing persona. This is useful when you have a complete persona profile to apply.
Sourcepub fn remove_persona(&self, id: &str) -> bool
pub fn remove_persona(&self, id: &str) -> bool
Remove a persona
Sourcepub fn list_persona_ids(&self) -> Vec<String>
pub fn list_persona_ids(&self) -> Vec<String>
Get all persona IDs
Get all personas that have a relationship of the specified type with the given persona
Returns a vector of persona profiles that are related to the specified persona.
Sourcepub fn find_personas_with_relationship_to(
&self,
target_persona_id: &str,
relationship_type: &str,
) -> Vec<PersonaProfile>
pub fn find_personas_with_relationship_to( &self, target_persona_id: &str, relationship_type: &str, ) -> Vec<PersonaProfile>
Find all personas that have a relationship pointing to the specified persona
This performs a reverse lookup to find personas that reference the given persona.
Sourcepub fn add_relationship(
&self,
from_persona_id: &str,
relationship_type: String,
to_persona_id: String,
) -> Result<()>
pub fn add_relationship( &self, from_persona_id: &str, relationship_type: String, to_persona_id: String, ) -> Result<()>
Add a relationship between two personas
Creates a relationship from from_persona_id to to_persona_id of the specified type.
Sourcepub fn coherent_persona_switch<F>(
&self,
root_persona_id: &str,
relationship_types: Option<&[String]>,
update_callback: Option<F>,
) -> Result<Vec<String>>
pub fn coherent_persona_switch<F>( &self, root_persona_id: &str, relationship_types: Option<&[String]>, update_callback: Option<F>, ) -> Result<Vec<String>>
Switch to a new persona and update all related personas in the graph
This ensures coherent persona switching across related entities. When switching to a new root persona, all related personas (orders, payments, etc.) are also updated to maintain consistency.
§Arguments
root_persona_id- The root persona ID to switch to (e.g., user ID)relationship_types- Optional filter for relationship types to followupdate_callback- Optional callback to update each related persona
§Returns
Vector of persona IDs that were updated
Trait Implementations§
Source§impl Clone for PersonaRegistry
impl Clone for PersonaRegistry
Source§fn clone(&self) -> PersonaRegistry
fn clone(&self) -> PersonaRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more