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§
Source§impl LiveHandle
impl LiveHandle
Sourcepub async fn send_audio(&self, data: Vec<u8>) -> Result<(), SessionError>
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.
Sourcepub async fn send_text(
&self,
text: impl Into<String>,
) -> Result<(), SessionError>
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.
Sourcepub async fn send_video(&self, jpeg_data: Vec<u8>) -> Result<(), SessionError>
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.
Sourcepub async fn update_instruction(
&self,
instruction: impl Into<String>,
) -> Result<(), SessionError>
pub async fn update_instruction( &self, instruction: impl Into<String>, ) -> Result<(), SessionError>
Update the system instruction mid-session.
Sourcepub async fn send_tool_response(
&self,
responses: Vec<FunctionResponse>,
) -> Result<(), SessionError>
pub async fn send_tool_response( &self, responses: Vec<FunctionResponse>, ) -> Result<(), SessionError>
Send tool responses manually (if not using auto-dispatch).
Sourcepub async fn playback_drained(&self) -> Result<(), SessionError>
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.
Sourcepub async fn user_speech_started(&self) -> Result<(), SessionError>
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.
Sourcepub async fn user_speech_ended(&self) -> Result<(), SessionError>
pub async fn user_speech_ended(&self) -> Result<(), SessionError>
Notify the runtime that client-side user speech has ended.
Sourcepub fn voice_state(&self) -> VoiceRuntimeState
pub fn voice_state(&self) -> VoiceRuntimeState
Snapshot the reactor-owned voice runtime state.
Sourcepub fn input_vad_state(&self) -> BackendVadSnapshot
pub fn input_vad_state(&self) -> BackendVadSnapshot
Snapshot backend input VAD state.
Sourcepub async fn flush_deferred_prompt(&self) -> Result<(), SessionError>
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.
Sourcepub fn writer(&self) -> Arc<dyn SessionWriter>
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.
Sourcepub fn subscribe(&self) -> Receiver<SessionEvent>
pub fn subscribe(&self) -> Receiver<SessionEvent>
Subscribe to raw session events (for custom processing).
Sourcepub async fn disconnect(&self) -> Result<(), SessionError>
pub async fn disconnect(&self) -> Result<(), SessionError>
Gracefully disconnect the session.
Sourcepub async fn done(&self) -> Result<(), SessionError>
pub async fn done(&self) -> Result<(), SessionError>
Wait for the session to end (disconnect, GoAway, or error).
Sourcepub fn state(&self) -> &State
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.
Sourcepub fn telemetry(&self) -> &Arc<SessionTelemetry>
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.
Sourcepub fn events(&self) -> Receiver<LiveEvent>
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.
Sourcepub fn extracted<T: DeserializeOwned>(&self, name: &str) -> Option<T>
pub fn extracted<T: DeserializeOwned>(&self, name: &str) -> Option<T>
Convenience: get the latest extraction result by extractor name.
Trait Implementations§
Source§impl Clone for LiveHandle
impl Clone for LiveHandle
Source§fn clone(&self) -> LiveHandle
fn clone(&self) -> LiveHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more