pub trait RealtimeSession: Send + Sync {
Show 18 methods
// Required methods
fn session_id(&self) -> &str;
fn is_connected(&self) -> bool;
fn send_audio<'life0, 'life1, 'async_trait>(
&'life0 self,
audio: &'life1 AudioChunk,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn send_audio_base64<'life0, 'life1, 'async_trait>(
&'life0 self,
audio_base64: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn send_text<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn send_tool_response<'life0, 'async_trait>(
&'life0 self,
response: ToolResponse,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn commit_audio<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn clear_audio<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn create_response<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn send_event<'life0, 'async_trait>(
&'life0 self,
event: ClientEvent,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn next_event<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Result<ServerEvent, RealtimeError>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn events(
&self,
) -> Pin<Box<dyn Stream<Item = Result<ServerEvent, RealtimeError>> + Send + '_>>;
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn mutate_context<'life0, 'async_trait>(
&'life0 self,
config: RealtimeConfig,
) -> Pin<Box<dyn Future<Output = Result<ContextMutationOutcome, RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn disconnect_reason(&self) -> Option<DisconnectReason> { ... }
fn send_video_frame<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_mime_type: &'life1 str,
_data_base64: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
fn send_tool_output<'life0, 'async_trait>(
&'life0 self,
response: ToolResponse,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
}realtime only.Required Methods§
Sourcefn session_id(&self) -> &str
fn session_id(&self) -> &str
Get the session ID.
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Check if the session is currently connected.
Sourcefn send_audio<'life0, 'life1, 'async_trait>(
&'life0 self,
audio: &'life1 AudioChunk,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn send_audio<'life0, 'life1, 'async_trait>(
&'life0 self,
audio: &'life1 AudioChunk,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Send raw audio data to the server.
The audio should be in the format specified in the session configuration.
Sourcefn send_audio_base64<'life0, 'life1, 'async_trait>(
&'life0 self,
audio_base64: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn send_audio_base64<'life0, 'life1, 'async_trait>(
&'life0 self,
audio_base64: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Send base64-encoded audio directly.
Sourcefn send_text<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn send_text<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Send a text message.
Sourcefn send_tool_response<'life0, 'async_trait>(
&'life0 self,
response: ToolResponse,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn send_tool_response<'life0, 'async_trait>(
&'life0 self,
response: ToolResponse,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Send a tool/function response (output and a response trigger).
Sourcefn commit_audio<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn commit_audio<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Commit the audio buffer (for manual VAD mode).
Sourcefn clear_audio<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn clear_audio<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Clear the audio input buffer.
Sourcefn create_response<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_response<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Trigger a response from the model.
Sourcefn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Interrupt/cancel the current response.
Sourcefn send_event<'life0, 'async_trait>(
&'life0 self,
event: ClientEvent,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn send_event<'life0, 'async_trait>(
&'life0 self,
event: ClientEvent,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Send a raw client event.
Sourcefn next_event<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Result<ServerEvent, RealtimeError>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn next_event<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Result<ServerEvent, RealtimeError>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Get the next event from the server.
Returns None when the session is closed.
Sourcefn events(
&self,
) -> Pin<Box<dyn Stream<Item = Result<ServerEvent, RealtimeError>> + Send + '_>>
fn events( &self, ) -> Pin<Box<dyn Stream<Item = Result<ServerEvent, RealtimeError>> + Send + '_>>
Get a stream of server events.
Sourcefn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Close the session gracefully.
Sourcefn mutate_context<'life0, 'async_trait>(
&'life0 self,
config: RealtimeConfig,
) -> Pin<Box<dyn Future<Output = Result<ContextMutationOutcome, RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn mutate_context<'life0, 'async_trait>(
&'life0 self,
config: RealtimeConfig,
) -> Pin<Box<dyn Future<Output = Result<ContextMutationOutcome, RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Attempt to mutate the session parameters mid-flight.
For providers that support native hot-swapping (e.g., OpenAI), this
mutates the parameters without tearing down the connection and returns Ok(ContextMutationOutcome::Applied).
For providers that require a static configuration (e.g., Gemini), this
returns Ok(ContextMutationOutcome::RequiresResumption(config)) to signal
the runner to queue a session reconnect or resumption safely.
Provided Methods§
Sourcefn disconnect_reason(&self) -> Option<DisconnectReason>
fn disconnect_reason(&self) -> Option<DisconnectReason>
Why the stream ended, if the provider said and the session recorded it.
Defaulted to None so existing sessions keep compiling; a provider that
sees a close frame should override it. Only meaningful after the event
stream has ended — before that it reports whatever the last close was,
which for a live session is nothing.
Sourcefn send_video_frame<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_mime_type: &'life1 str,
_data_base64: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn send_video_frame<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_mime_type: &'life1 str,
_data_base64: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Send a single video/image frame (base64-encoded, e.g. a JPEG) to the
model for multimodal input. mime_type is the frame’s media type
(e.g. image/jpeg). The default is a no-op for providers/sessions that
don’t accept visual input.
Sourcefn send_tool_output<'life0, 'async_trait>(
&'life0 self,
response: ToolResponse,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn send_tool_output<'life0, 'async_trait>(
&'life0 self,
response: ToolResponse,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Send a tool/function output without triggering a response.
When one model response dispatches several parallel tool calls, send each
output with this method and then call
create_response exactly once — issuing a
response.create per output would collide with the still-active response
on providers like OpenAI. The default delegates to
send_tool_response for backends that do not
separate the two.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".