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
pub fn new(config: ConnectionConfig) -> Self
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.
pub fn is_connected(&self) -> bool
pub fn connect_attempts(&self) -> u32
pub fn config(&self) -> &ConnectionConfig
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