pub trait EventHandler: Send + Sync {
// Provided methods
fn on_audio<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_audio: &'life1 [u8],
_item_id: &'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 on_text<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_text: &'life1 str,
_item_id: &'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 on_transcript<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_transcript: &'life1 str,
_item_id: &'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 on_speech_started<'life0, 'async_trait>(
&'life0 self,
_audio_start_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn on_speech_stopped<'life0, 'async_trait>(
&'life0 self,
_audio_end_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn on_response_done<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn on_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn on_error<'life0, 'life1, 'async_trait>(
&'life0 self,
_error: &'life1 RealtimeError,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
}realtime only.Expand description
Event handler for processing realtime events.
Provided Methods§
Sourcefn on_audio<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_audio: &'life1 [u8],
_item_id: &'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 on_audio<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_audio: &'life1 [u8],
_item_id: &'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,
Called when an audio delta is received (raw PCM bytes).
Sourcefn on_text<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_text: &'life1 str,
_item_id: &'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 on_text<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_text: &'life1 str,
_item_id: &'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,
Called when a text delta is received.
Sourcefn on_transcript<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_transcript: &'life1 str,
_item_id: &'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 on_transcript<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_transcript: &'life1 str,
_item_id: &'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,
Called when a transcript delta is received.
Sourcefn on_speech_started<'life0, 'async_trait>(
&'life0 self,
_audio_start_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn on_speech_started<'life0, 'async_trait>(
&'life0 self,
_audio_start_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Called when speech is detected.
Sourcefn on_speech_stopped<'life0, 'async_trait>(
&'life0 self,
_audio_end_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn on_speech_stopped<'life0, 'async_trait>(
&'life0 self,
_audio_end_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Called when speech ends.
Sourcefn on_response_done<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn on_response_done<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Called when a response completes.
Sourcefn on_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn on_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Called on any error.
Called when the provider transport ends and RealtimeRunner::run is returning.
The runner does not reconnect automatically. Reconnection is deliberate: it
requires deciding what context to replay and, on Gemini, whether a resumption token
is still valid. Without this hook run returned Ok(()) on transport loss, which a
caller could not tell apart from a graceful RealtimeRunner::close.
§Example
async fn on_disconnect(&self) -> adk_realtime::Result<()> {
tracing::warn!("realtime transport ended; reconnecting");
self.reconnect.notify_one();
Ok(())
}fn on_error<'life0, 'life1, 'async_trait>(
&'life0 self,
_error: &'life1 RealtimeError,
) -> Pin<Box<dyn Future<Output = Result<(), RealtimeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".