pub struct WsManager { /* private fields */ }Expand description
Manages a single WebSocket feed: connect, receive, reconnect.
In production, WsManager wraps tokio-tungstenite. In tests, it operates in simulation mode with injected messages.
Implementations§
Source§impl WsManager
impl WsManager
Sourcepub fn new(config: ConnectionConfig) -> Self
pub fn new(config: ConnectionConfig) -> Self
Create a new manager from a validated ConnectionConfig.
Sourcepub fn connect_simulated(&mut self)
pub fn connect_simulated(&mut self)
Simulate a connection (for testing without live WebSocket).
Increments connect_attempts to reflect the initial connection slot.
Sourcepub fn disconnect_simulated(&mut self)
pub fn disconnect_simulated(&mut self)
Simulate a disconnection.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether the managed connection is currently in the connected state.
Sourcepub fn connect_attempts(&self) -> u32
pub fn connect_attempts(&self) -> u32
Total connection attempts made so far (including the initial connect).
Sourcepub fn config(&self) -> &ConnectionConfig
pub fn config(&self) -> &ConnectionConfig
The configuration this manager was created with.
Sourcepub fn can_reconnect(&self) -> bool
pub fn can_reconnect(&self) -> bool
Check whether the next reconnect attempt is allowed.
Sourcepub fn next_reconnect_backoff(&mut self) -> Result<Duration, StreamError>
pub fn next_reconnect_backoff(&mut self) -> Result<Duration, StreamError>
Consume a reconnect slot and return the backoff duration to wait.
Auto Trait Implementations§
impl Freeze for WsManager
impl RefUnwindSafe for WsManager
impl Send for WsManager
impl Sync for WsManager
impl Unpin for WsManager
impl UnsafeUnpin for WsManager
impl UnwindSafe for WsManager
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