pub struct SessionState {
pub session_id: String,
pub resume_handle: Mutex<Option<String>>,
pub turns: Mutex<Vec<Turn>>,
pub current_turn: Mutex<Option<Turn>>,
/* private fields */
}Expand description
Shared session state, accessible from the SessionHandle.
Fields§
§session_id: StringSession ID.
resume_handle: Mutex<Option<String>>Session resume handle from server.
turns: Mutex<Vec<Turn>>Turn history.
current_turn: Mutex<Option<Turn>>Current in-progress turn.
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn new(phase_tx: Sender<SessionPhase>) -> Self
pub fn new(phase_tx: Sender<SessionPhase>) -> Self
Create new session state (no PhaseChanged event emission).
Sourcepub fn with_events(
phase_tx: Sender<SessionPhase>,
event_tx: Sender<SessionEvent>,
) -> Self
pub fn with_events( phase_tx: Sender<SessionPhase>, event_tx: Sender<SessionEvent>, ) -> Self
Create new session state that emits PhaseChanged events on transitions.
Sourcepub fn phase(&self) -> SessionPhase
pub fn phase(&self) -> SessionPhase
Get the current phase.
Sourcepub fn transition_to(
&self,
to: SessionPhase,
) -> Result<SessionPhase, SessionError>
pub fn transition_to( &self, to: SessionPhase, ) -> Result<SessionPhase, SessionError>
Attempt a validated phase transition.
If an event_tx was provided via with_events,
a SessionEvent::PhaseChanged is broadcast after a successful transition.
Sourcepub fn force_phase(&self, phase: SessionPhase)
pub fn force_phase(&self, phase: SessionPhase)
Force transition (bypasses validation — use only for disconnect).
Sourcepub fn start_turn(&self)
pub fn start_turn(&self)
Start a new turn.
Sourcepub fn append_text(&self, text: &str)
pub fn append_text(&self, text: &str)
Append text to the current turn.
Sourcepub fn mark_audio(&self)
pub fn mark_audio(&self)
Mark audio received in the current turn.
Sourcepub fn complete_turn(&self) -> Option<Turn>
pub fn complete_turn(&self) -> Option<Turn>
Complete the current turn.
Sourcepub fn interrupt_turn(&self)
pub fn interrupt_turn(&self)
Mark the current turn as interrupted.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SessionState
impl !RefUnwindSafe for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl !UnwindSafe for SessionState
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
Mutably borrows from an owned value. Read more