WebSocketClient

Trait WebSocketClient 

Source
pub trait WebSocketClient: Sync + Send {
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn connect(
        &self,
        url: Url,
    ) -> impl Future<Output = Result<WebSocketConnection, Self::Error>> + Send;

    // Provided method
    fn connect_with_headers(
        &self,
        url: Url,
        _headers: Vec<(CowStr<'_>, CowStr<'_>)>,
    ) -> impl Future<Output = Result<WebSocketConnection, Self::Error>> + Send { ... }
}
Expand description

WebSocket client trait

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Error type for WebSocket operations

Required Methods§

Source

fn connect( &self, url: Url, ) -> impl Future<Output = Result<WebSocketConnection, Self::Error>> + Send

Connect to a WebSocket endpoint

Provided Methods§

Source

fn connect_with_headers( &self, url: Url, _headers: Vec<(CowStr<'_>, CowStr<'_>)>, ) -> impl Future<Output = Result<WebSocketConnection, Self::Error>> + Send

Connect to a WebSocket endpoint with custom headers

Default implementation ignores headers and calls connect(). Override this method to support authentication headers for subscriptions.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§