pub struct ReconnectingWebSocket { /* private fields */ }Expand description
A WebSocket connection with automatic reconnection support.
This wrapper handles connection failures by automatically reconnecting with exponential backoff.
Implementations§
Source§impl ReconnectingWebSocket
impl ReconnectingWebSocket
Sourcepub async fn new(url: String, config: ReconnectConfig) -> Result<Self>
pub async fn new(url: String, config: ReconnectConfig) -> Result<Self>
Create a new reconnecting WebSocket connection.
Sourcepub async fn next(&mut self) -> Option<Result<WebSocketEvent>>
pub async fn next(&mut self) -> Option<Result<WebSocketEvent>>
Receive the next WebSocket event.
Sourcepub async fn state(&self) -> ConnectionState
pub async fn state(&self) -> ConnectionState
Get the current connection state.
Sourcepub fn reconnect_count(&self) -> u64
pub fn reconnect_count(&self) -> u64
Get the number of reconnection attempts.
Auto Trait Implementations§
impl Freeze for ReconnectingWebSocket
impl !RefUnwindSafe for ReconnectingWebSocket
impl Send for ReconnectingWebSocket
impl Sync for ReconnectingWebSocket
impl Unpin for ReconnectingWebSocket
impl !UnwindSafe for ReconnectingWebSocket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more