pub struct WebSocket { /* private fields */ }Expand description
WebSocket connection with TLS support and automatic ping/pong.
Wraps a tokio-tungstenite stream with browser-like headers and
transparent keep-alive handling. Ping frames received from the
server are automatically answered with Pong.
Implementations§
Source§impl WebSocket
impl WebSocket
Sourcepub async fn connect(url: &str, profile: &BrowserProfile) -> Result<Self>
pub async fn connect(url: &str, profile: &BrowserProfile) -> Result<Self>
Connect to a WebSocket endpoint
Sourcepub async fn recv(&mut self) -> Result<Option<WebSocketMessage>>
pub async fn recv(&mut self) -> Result<Option<WebSocketMessage>>
Receive the next application-level message.
Ping frames are answered automatically with Pong. Pong and raw Frame messages are silently consumed so the caller only sees Text, Binary, or Close messages.
Sourcepub async fn recv_timeout(
&mut self,
timeout: Duration,
) -> Result<Option<WebSocketMessage>>
pub async fn recv_timeout( &mut self, timeout: Duration, ) -> Result<Option<WebSocketMessage>>
Receive with timeout
Auto Trait Implementations§
impl !Freeze for WebSocket
impl !RefUnwindSafe for WebSocket
impl Send for WebSocket
impl Sync for WebSocket
impl Unpin for WebSocket
impl UnsafeUnpin for WebSocket
impl !UnwindSafe for WebSocket
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