pub struct PersonaLifecycle {
pub persona_id: String,
pub current_state: LifecycleState,
pub state_history: Vec<(DateTime<Utc>, LifecycleState)>,
pub transition_rules: Vec<TransitionRule>,
pub state_entered_at: DateTime<Utc>,
pub metadata: HashMap<String, Value>,
}Expand description
Persona lifecycle manager
Manages the lifecycle state of a persona, including state transitions based on pseudo-time and conditions.
Fields§
§persona_id: StringPersona ID
current_state: LifecycleStateCurrent lifecycle state
state_history: Vec<(DateTime<Utc>, LifecycleState)>History of state transitions
transition_rules: Vec<TransitionRule>Transition rules for this persona
state_entered_at: DateTime<Utc>State entered at time
metadata: HashMap<String, Value>Additional metadata for lifecycle tracking
Implementations§
Source§impl PersonaLifecycle
impl PersonaLifecycle
Sourcepub fn new(persona_id: String, initial_state: LifecycleState) -> Self
pub fn new(persona_id: String, initial_state: LifecycleState) -> Self
Create a new persona lifecycle with initial state
Sourcepub fn with_rules(
persona_id: String,
initial_state: LifecycleState,
transition_rules: Vec<TransitionRule>,
) -> Self
pub fn with_rules( persona_id: String, initial_state: LifecycleState, transition_rules: Vec<TransitionRule>, ) -> Self
Create a new persona lifecycle with transition rules
Sourcepub fn transition_if_elapsed(
&self,
current_time: DateTime<Utc>,
) -> Option<(LifecycleState, &TransitionRule)>
pub fn transition_if_elapsed( &self, current_time: DateTime<Utc>, ) -> Option<(LifecycleState, &TransitionRule)>
Check if a transition should occur based on elapsed time
Returns the target state if a transition should occur, None otherwise.
Sourcepub fn apply_lifecycle_effects(&self) -> HashMap<String, String>
pub fn apply_lifecycle_effects(&self) -> HashMap<String, String>
Apply lifecycle effects to persona traits
Updates persona traits based on the current lifecycle state.
Sourcepub fn transition_to(
&mut self,
new_state: LifecycleState,
transition_time: DateTime<Utc>,
)
pub fn transition_to( &mut self, new_state: LifecycleState, transition_time: DateTime<Utc>, )
Transition to a new state
Sourcepub fn current_state_duration(&self, current_time: DateTime<Utc>) -> Duration
pub fn current_state_duration(&self, current_time: DateTime<Utc>) -> Duration
Get the duration in the current state
Sourcepub fn set_metadata(&mut self, key: String, value: Value)
pub fn set_metadata(&mut self, key: String, value: Value)
Add metadata for lifecycle tracking
Sourcepub fn get_metadata(&self, key: &str) -> Option<&Value>
pub fn get_metadata(&self, key: &str) -> Option<&Value>
Get metadata value
Sourcepub fn from_preset(
preset: LifecyclePreset,
persona_id: String,
) -> PersonaLifecycle
pub fn from_preset( preset: LifecyclePreset, persona_id: String, ) -> PersonaLifecycle
Create a lifecycle from a preset
Trait Implementations§
Source§impl Clone for PersonaLifecycle
impl Clone for PersonaLifecycle
Source§fn clone(&self) -> PersonaLifecycle
fn clone(&self) -> PersonaLifecycle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more