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§
Sourcefn provider(&self) -> &ProviderId
fn provider(&self) -> &ProviderId
Provider identifier.
Sourcefn do_create_client_secret(
&self,
options: ClientSecretOptions,
) -> impl Future<Output = Result<ClientSecret, ProviderError>> + Send
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.
Sourcefn websocket_config(&self, token: &str, url: &Url) -> WebSocketConfig
fn websocket_config(&self, token: &str, url: &Url) -> WebSocketConfig
Returns the WebSocket URL and sub-protocols for a token.
Sourcefn parse_server_event(
&self,
raw: JsonValue,
) -> Result<Vec<RealtimeServerEvent>, ProviderError>
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.
Sourcefn serialize_client_event(
&self,
event: RealtimeClientEvent,
) -> impl Future<Output = Result<JsonValue, ProviderError>> + Send
fn serialize_client_event( &self, event: RealtimeClientEvent, ) -> impl Future<Output = Result<JsonValue, ProviderError>> + Send
Converts a standardized client event into the provider wire format.
Sourcefn build_session_config(
&self,
config: &RealtimeSessionConfig,
) -> Result<JsonValue, ProviderError>
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§
Sourcefn health_check_response(&self, raw: &JsonValue) -> Option<JsonValue>
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".