pub struct BinanceWebSocketManager {
pub ws_sink: Arc<RwLock<Option<WebSocketSink>>>,
pub ws_stream: Arc<RwLock<Option<WebSocketStream>>>,
pub state: Arc<AtomicU8>,
pub connected: AtomicBool,
}Expand description
Shared WebSocket connection manager for Binance connections
Fields§
§ws_sink: Arc<RwLock<Option<WebSocketSink>>>WebSocket sink for sending messages
ws_stream: Arc<RwLock<Option<WebSocketStream>>>WebSocket stream for receiving messages
state: Arc<AtomicU8>Connection state (atomic for lock-free access)
connected: AtomicBoolSimple connected flag for basic checks
Implementations§
Source§impl BinanceWebSocketManager
impl BinanceWebSocketManager
Sourcepub fn get_state(&self) -> ConnectionState
pub fn get_state(&self) -> ConnectionState
Get current connection state
Sourcepub fn set_state(&self, state: ConnectionState)
pub fn set_state(&self, state: ConnectionState)
Set connection state
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected
Sourcepub async fn connect_with_retry(&self, ws_url: &str) -> Result<()>
pub async fn connect_with_retry(&self, ws_url: &str) -> Result<()>
Connect to WebSocket with automatic retry
Sourcepub async fn disconnect(&self) -> Result<()>
pub async fn disconnect(&self) -> Result<()>
Disconnect WebSocket connection
Sourcepub fn get_stream_handle(&self) -> Arc<AsyncRwLock<Option<WebSocketStream>>>
pub fn get_stream_handle(&self) -> Arc<AsyncRwLock<Option<WebSocketStream>>>
Get a cloned stream handle for message processing
Sourcepub fn get_sink_handle(&self) -> Arc<AsyncRwLock<Option<WebSocketSink>>>
pub fn get_sink_handle(&self) -> Arc<AsyncRwLock<Option<WebSocketSink>>>
Get a cloned sink handle for sending messages
Trait Implementations§
Source§impl Clone for BinanceWebSocketManager
impl Clone for BinanceWebSocketManager
Auto Trait Implementations§
impl !Freeze for BinanceWebSocketManager
impl !RefUnwindSafe for BinanceWebSocketManager
impl Send for BinanceWebSocketManager
impl Sync for BinanceWebSocketManager
impl Unpin for BinanceWebSocketManager
impl !UnwindSafe for BinanceWebSocketManager
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