pub struct WebSocket { /* private fields */ }Implementations§
Source§impl WebSocket
impl WebSocket
Sourcepub fn new(upgraded: Upgraded, config: WebSocketConfig) -> WebSocket
pub fn new(upgraded: Upgraded, config: WebSocketConfig) -> WebSocket
Take over a connection the HTTP server has finished with.
Sourcepub fn on_path(self, path: impl Into<String>) -> Self
pub fn on_path(self, path: impl Into<String>) -> Self
Label the socket for instrumentation with the route it was opened on.
pub fn with_protocol(self, protocol: Option<String>) -> Self
pub fn path(&self) -> &str
pub fn is_closed(&self) -> bool
Sourcepub fn close_frame(&self) -> Option<&CloseFrame>
pub fn close_frame(&self) -> Option<&CloseFrame>
How the connection ended, once it has. Available after recv returns
None, which is where an application usually wants to log it.
pub async fn send(&mut self, message: impl Into<Message>) -> WsResult<()>
Sourcepub async fn recv(&mut self) -> Option<Message>
pub async fn recv(&mut self) -> Option<Message>
The next message from the peer, or None once the connection is over.
Only Text and Binary come out of here. Pings, pongs and closes are
answered internally, because every application would have to write the
same three replies and one of them would get it wrong.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WebSocket
impl !Sync for WebSocket
impl !UnwindSafe for WebSocket
impl Freeze for WebSocket
impl Send for WebSocket
impl Unpin for WebSocket
impl UnsafeUnpin 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