Skip to main content

RealtimeModel

Trait RealtimeModel 

Source
pub trait RealtimeModel:
    Send
    + Sync
    + 'static {
    // Required methods
    fn provider(&self) -> &ProviderId;
    fn model_id(&self) -> &ModelId;
    fn do_create_client_secret(
        &self,
        options: ClientSecretOptions,
    ) -> impl Future<Output = Result<ClientSecret, ProviderError>> + Send;
    fn websocket_config(&self, token: &str, url: &Url) -> WebSocketConfig;
    fn parse_server_event(
        &self,
        raw: JsonValue,
    ) -> Result<Vec<RealtimeServerEvent>, ProviderError>;
    fn serialize_client_event(
        &self,
        event: RealtimeClientEvent,
    ) -> impl Future<Output = Result<JsonValue, ProviderError>> + Send;
    fn build_session_config(
        &self,
        config: &RealtimeSessionConfig,
    ) -> Result<JsonValue, ProviderError>;

    // Provided method
    fn health_check_response(&self, raw: &JsonValue) -> Option<JsonValue> { ... }
}
Expand description

A realtime model.

Required Methods§

Source

fn provider(&self) -> &ProviderId

Provider identifier.

Source

fn model_id(&self) -> &ModelId

Model identifier.

Source

fn do_create_client_secret( &self, options: ClientSecretOptions, ) -> impl Future<Output = Result<ClientSecret, ProviderError>> + Send

Creates a short-lived client secret for opening a session.

Source

fn websocket_config(&self, token: &str, url: &Url) -> WebSocketConfig

Returns the WebSocket URL and sub-protocols for a token.

Source

fn parse_server_event( &self, raw: JsonValue, ) -> Result<Vec<RealtimeServerEvent>, ProviderError>

Converts a raw server message into zero or more standardized events.

§Errors

Returns an error when the message cannot be interpreted at all; unknown but well-formed messages should map to RealtimeServerEvent::Custom.

Source

fn serialize_client_event( &self, event: RealtimeClientEvent, ) -> impl Future<Output = Result<JsonValue, ProviderError>> + Send

Converts a standardized client event into the provider wire format.

Source

fn build_session_config( &self, config: &RealtimeSessionConfig, ) -> Result<JsonValue, ProviderError>

Converts a session configuration into the provider wire format.

§Errors

Returns an error when the configuration cannot be expressed.

Provided Methods§

Source

fn health_check_response(&self, raw: &JsonValue) -> Option<JsonValue>

Returns the reply to send when raw is a provider health-check ping.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§