pub trait WebSocketSource:
Send
+ Sync
+ StreamExt<Item = Result<WebsocketMessage, Error>>
+ FusedStream
+ Unpin
+ 'static {
// Required methods
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
symbols: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
symbols: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn is_connected<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Represents a source for streaming WebSocket messages.
This trait defines methods for connecting to a WebSocket, subscribing and unsubscribing to symbols, checking the connection status, and streaming WebSocket messages.
Required Methods§
Sourcefn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Asynchronously establishes a connection to the WebSocket.
Sourcefn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
symbols: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
symbols: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Asynchronously subscribes to the specified symbols on the WebSocket.
Returns the number of symbols successfully subscribed.
Sourcefn unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
symbols: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
symbols: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<u32, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Asynchronously unsubscribes from the specified symbols on the WebSocket.
Returns the number of symbols successfully unsubscribed.
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.