pub struct EventHandler { /* private fields */ }Expand description
Callback-based event handler for processing server events.
§Example
use openai_tools::realtime::EventHandler;
use openai_tools::realtime::events::server::ServerEvent;
let mut handler = EventHandler::new();
handler
.on_text_delta(|e| {
print!("{}", e.delta);
})
.on_audio_delta(|e| {
// Play audio: base64::decode(&e.delta)
})
.on_error(|e| {
eprintln!("Error: {}", e.error.message);
});
// In your event loop:
// handler.handle(&event);Implementations§
Source§impl EventHandler
impl EventHandler
Sourcepub fn on_session_created<F>(&mut self, f: F) -> &mut Self
pub fn on_session_created<F>(&mut self, f: F) -> &mut Self
Set callback for session.created events.
Sourcepub fn on_session_updated<F>(&mut self, f: F) -> &mut Self
pub fn on_session_updated<F>(&mut self, f: F) -> &mut Self
Set callback for session.updated events.
Sourcepub fn on_conversation_item_created<F>(&mut self, f: F) -> &mut Self
pub fn on_conversation_item_created<F>(&mut self, f: F) -> &mut Self
Set callback for conversation.item.created events.
Sourcepub fn on_input_audio_transcription_completed<F>(&mut self, f: F) -> &mut Self
pub fn on_input_audio_transcription_completed<F>(&mut self, f: F) -> &mut Self
Set callback for input audio transcription completed events.
Sourcepub fn on_speech_started<F>(&mut self, f: F) -> &mut Self
pub fn on_speech_started<F>(&mut self, f: F) -> &mut Self
Set callback for speech started events.
Sourcepub fn on_speech_stopped<F>(&mut self, f: F) -> &mut Self
pub fn on_speech_stopped<F>(&mut self, f: F) -> &mut Self
Set callback for speech stopped events.
Sourcepub fn on_response_created<F>(&mut self, f: F) -> &mut Self
pub fn on_response_created<F>(&mut self, f: F) -> &mut Self
Set callback for response.created events.
Sourcepub fn on_response_done<F>(&mut self, f: F) -> &mut Self
pub fn on_response_done<F>(&mut self, f: F) -> &mut Self
Set callback for response.done events.
Sourcepub fn on_text_delta<F>(&mut self, f: F) -> &mut Self
pub fn on_text_delta<F>(&mut self, f: F) -> &mut Self
Set callback for response.text.delta events.
Sourcepub fn on_text_done<F>(&mut self, f: F) -> &mut Self
pub fn on_text_done<F>(&mut self, f: F) -> &mut Self
Set callback for response.text.done events.
Sourcepub fn on_audio_delta<F>(&mut self, f: F) -> &mut Self
pub fn on_audio_delta<F>(&mut self, f: F) -> &mut Self
Set callback for response.audio.delta events.
Sourcepub fn on_audio_done<F>(&mut self, f: F) -> &mut Self
pub fn on_audio_done<F>(&mut self, f: F) -> &mut Self
Set callback for response.audio.done events.
Sourcepub fn on_audio_transcript_delta<F>(&mut self, f: F) -> &mut Self
pub fn on_audio_transcript_delta<F>(&mut self, f: F) -> &mut Self
Set callback for response.audio_transcript.delta events.
Sourcepub fn on_audio_transcript_done<F>(&mut self, f: F) -> &mut Self
pub fn on_audio_transcript_done<F>(&mut self, f: F) -> &mut Self
Set callback for response.audio_transcript.done events.
Sourcepub fn on_function_call_arguments_delta<F>(&mut self, f: F) -> &mut Self
pub fn on_function_call_arguments_delta<F>(&mut self, f: F) -> &mut Self
Set callback for function call arguments delta events.
Sourcepub fn on_function_call_arguments_done<F>(&mut self, f: F) -> &mut Self
pub fn on_function_call_arguments_done<F>(&mut self, f: F) -> &mut Self
Set callback for function call arguments done events.
Sourcepub fn on_rate_limits_updated<F>(&mut self, f: F) -> &mut Self
pub fn on_rate_limits_updated<F>(&mut self, f: F) -> &mut Self
Set callback for rate limits updated events.
Sourcepub fn handle(&self, event: &ServerEvent)
pub fn handle(&self, event: &ServerEvent)
Process a server event, calling the appropriate callback.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventHandler
impl !RefUnwindSafe for EventHandler
impl Send for EventHandler
impl Sync for EventHandler
impl Unpin for EventHandler
impl !UnwindSafe for EventHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().