LiveHandle

Struct LiveHandle 

pub struct LiveHandle { /* private fields */ }
Expand description

Handle for interacting with a running Live session.

Provides send methods for audio/text/video, system instruction updates, event subscription, state access, telemetry, and graceful shutdown.

When ContextDelivery::Deferred is enabled, send_audio, send_text, and send_video automatically flush any pending context turns before forwarding the user content.

Implementations§

§

impl LiveHandle

pub async fn send_audio(&self, data: Vec<u8>) -> Result<(), SessionError>

Send audio data (raw PCM16 16kHz bytes).

When deferred context delivery is enabled, any pending model-role context turns are flushed to the wire before the audio frame.

pub async fn send_text( &self, text: impl Into<String>, ) -> Result<(), SessionError>

Send a text message.

When deferred context delivery is enabled, any pending model-role context turns are flushed to the wire before the text message.

pub async fn send_video(&self, jpeg_data: Vec<u8>) -> Result<(), SessionError>

Send a video/image frame (raw JPEG bytes).

When deferred context delivery is enabled, any pending model-role context turns are flushed to the wire before the video frame.

pub async fn update_instruction( &self, instruction: impl Into<String>, ) -> Result<(), SessionError>

Update the system instruction mid-session.

pub async fn send_tool_response( &self, responses: Vec<FunctionResponse>, ) -> Result<(), SessionError>

Send tool responses manually (if not using auto-dispatch).

pub async fn playback_drained(&self) -> Result<(), SessionError>

Notify the runtime that client-side playback has drained.

Voice UIs should call this only when it is safe for the model to speak, for example after browser speaker playback has drained and the user is not actively speaking. User audio/text sends intentionally flush context only and leave the prompt armed.

pub async fn user_speech_started(&self) -> Result<(), SessionError>

Notify the runtime that client-side user speech has started.

This is the barge-in edge for voice clients: pending model prompts are cancelled before they can race with user audio, while queued context is kept so the next user send can still carry it.

pub async fn user_speech_ended(&self) -> Result<(), SessionError>

Notify the runtime that client-side user speech has ended.

pub fn voice_state(&self) -> VoiceRuntimeState

Snapshot the reactor-owned voice runtime state.

pub fn input_vad_state(&self) -> BackendVadSnapshot

Snapshot backend input VAD state.

pub async fn flush_deferred_prompt(&self) -> Result<(), SessionError>

Flush deferred context and any pending model prompt.

Prefer Self::playback_drained for voice clients. This compatibility method routes through the same reactor/effect executor path.

pub fn writer(&self) -> Arc<dyn SessionWriter>

Get the user-facing session writer.

When deferred context delivery is enabled, this returns the DeferredWriter that flushes pending context before sends.

pub fn subscribe(&self) -> Receiver<SessionEvent>

Subscribe to raw session events (for custom processing).

pub fn phase(&self) -> SessionPhase

Get the current session phase.

pub async fn disconnect(&self) -> Result<(), SessionError>

Gracefully disconnect the session.

pub async fn done(&self) -> Result<(), SessionError>

Wait for the session to end (disconnect, GoAway, or error).

pub fn session(&self) -> &SessionHandle

Get the underlying SessionHandle for advanced usage.

pub fn state(&self) -> &State

Access the shared State container.

Extraction results from TurnExtractors are stored here under the extractor’s name. Use state().get::<T>(name) to read typed values.

pub fn telemetry(&self) -> &Arc<SessionTelemetry>

Access the session telemetry (auto-collected by the telemetry lane).

Use telemetry().snapshot() to get a JSON snapshot of all metrics.

pub fn events(&self) -> Receiver<LiveEvent>

Subscribe to semantic events from the processor.

Returns a broadcast receiver. Call multiple times for independent subscribers. Zero-cost when no subscribers exist.

pub fn extracted<T>(&self, name: &str) -> Option<T>

Convenience: get the latest extraction result by extractor name.

Trait Implementations§

§

impl Clone for LiveHandle

§

fn clone(&self) -> LiveHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more