pub trait ClientExt: Send {
type Call: Send;
// Required methods
fn on_text<'life0, 'async_trait>(
&'life0 mut self,
text: Utf8Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_binary<'life0, 'async_trait>(
&'life0 mut self,
bytes: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_call<'life0, 'async_trait>(
&'life0 mut self,
call: Self::Call,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn on_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 on_connect_fail<'life0, 'async_trait>(
&'life0 mut self,
_error: WSError,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_close<'life0, 'async_trait>(
&'life0 mut self,
_frame: Option<CloseFrame>,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}client only.Required Associated Types§
Required Methods§
Sourcefn on_text<'life0, 'async_trait>(
&'life0 mut self,
text: Utf8Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_text<'life0, 'async_trait>(
&'life0 mut self,
text: Utf8Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handler for text messages from the server.
Returning an error will force-close the client.
Sourcefn on_binary<'life0, 'async_trait>(
&'life0 mut self,
bytes: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_binary<'life0, 'async_trait>(
&'life0 mut self,
bytes: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handler for binary messages from the server.
Returning an error will force-close the client.
Sourcefn on_call<'life0, 'async_trait>(
&'life0 mut self,
call: Self::Call,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_call<'life0, 'async_trait>(
&'life0 mut self,
call: Self::Call,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handler for custom calls from other parts from your program.
Returning an error will force-close the client.
This is useful for concurrency and polymorphism.
Provided Methods§
Sourcefn on_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 on_connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called when the client successfully connected (or reconnected).
Returning an error will force-close the client.
Sourcefn on_connect_fail<'life0, 'async_trait>(
&'life0 mut self,
_error: WSError,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_connect_fail<'life0, 'async_trait>(
&'life0 mut self,
_error: WSError,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called when the client fails a connection/reconnection attempt.
Returning an error will force-close the client.
By default, the client will continue trying to connect.
Return ClientCloseMode::Close here to fully close instead.
Sourcefn on_close<'life0, 'async_trait>(
&'life0 mut self,
_frame: Option<CloseFrame>,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_close<'life0, 'async_trait>(
&'life0 mut self,
_frame: Option<CloseFrame>,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called when the connection is closed by the server.
Returning an error will force-close the client.
By default, the client will try to reconnect. Return ClientCloseMode::Close here to fully close instead.
For reconnections, use ClientConfig::reconnect_interval.
Sourcefn on_disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<ClientCloseMode, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called when the connection is closed by the socket dying.
Returning an error will force-close the client.
By default, the client will try to reconnect. Return ClientCloseMode::Close here to fully close instead.
For reconnections, use ClientConfig::reconnect_interval.