pub struct SessionSignals { /* private fields */ }Expand description
Tracks session-level signals automatically from events.
Every call to on_event updates the
corresponding keys under session: in the shared State, making
them available to instruction templates, watchers, and computed vars.
Performance: Timestamps use AtomicU64 (nanos since session start)
instead of Mutex<Instant>. Derived timing signals are flushed
periodically via flush_timing() (100ms interval) rather than per-event.
Implementations§
Source§impl SessionSignals
impl SessionSignals
Sourcepub fn new(state: State) -> SessionSignals
pub fn new(state: State) -> SessionSignals
Create a new SessionSignals backed by the given State.
Sourcepub fn on_event(&self, event: &SessionEvent)
pub fn on_event(&self, event: &SessionEvent)
Process an event — updates state keys and atomic timestamps.
This is the per-event handler. It updates boolean flags, counters,
and atomic timestamps. Derived timing (silence_ms, elapsed_ms,
remaining_budget_ms) is NOT computed here — call flush_timing()
periodically instead.
Sourcepub fn flush_timing(&self)
pub fn flush_timing(&self)
Flush derived timing signals to state.
Call this periodically (e.g., every 100ms) from the telemetry lane.
Computes silence_ms, elapsed_ms, and remaining_budget_ms from
atomic timestamps without any mutex locks.
Sourcepub fn record_response_latency(&self, latency: Duration)
pub fn record_response_latency(&self, latency: Duration)
Record the turn’s response latency (end of user speech, or text send,
to the model’s first output) as session:last_response_latency_ms, so
instruction templates, watchers and computed vars can react to a slow
turn. Called by the telemetry lane once per measured turn.
The write happens when the turn’s first output event is observed, so for a spoken turn it lands a whole model response before the boundary. The telemetry and control lanes are independent readers of the same event stream, though, with no barrier between them: if the telemetry lane is running behind, a turn-boundary reader can still see the previous turn’s value. Treat the key as the latest measurement, not as one synchronised to the current turn.
Sourcepub fn session_type(&self) -> SessionType
pub fn session_type(&self) -> SessionType
Returns the current session type based on whether video has been sent.
Sourcepub fn latest_resume_handle(&self) -> Option<String>
pub fn latest_resume_handle(&self) -> Option<String>
Returns the latest resumption handle for reconnection.
Sourcepub fn mark_video_sent(&self)
pub fn mark_video_sent(&self)
Mark that video has been sent (changes session type to AudioVideo).
Auto Trait Implementations§
impl !Freeze for SessionSignals
impl !RefUnwindSafe for SessionSignals
impl Send for SessionSignals
impl Sync for SessionSignals
impl Unpin for SessionSignals
impl !UnwindSafe for SessionSignals
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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].