Skip to main content

EventHandler

Trait EventHandler 

Source
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_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 { ... }
}
Available on crate feature realtime only.
Expand description

Event handler for processing realtime events.

Provided Methods§

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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,

Called on any error.

Implementors§