pub struct WebSocket { /* private fields */ }Available on crate feature
ws only.Implementations§
source§impl WebSocket
impl WebSocket
pub async fn new(upgraded: Upgraded) -> Self
sourcepub async fn receive(&mut self) -> Result<Option<Message>, Error>
pub async fn receive(&mut self) -> Result<Option<Message>, Error>
Handles Ping and Pong messages
never returns Error::ConnectionClose | Error::AlreadyClosed
pub async fn send<M>(&mut self, msg: M) -> Result<(), Error>where
M: Into<Message>,
pub async fn close(&mut self, code: CloseCode, reason: String)
pub async fn ping(&mut self) -> Result<(), Error>
sourcepub async fn deserialize<D>(&mut self) -> Result<Option<D>, JsonError>where
D: DeserializeOwned,
Available on crate feature json only.
pub async fn deserialize<D>(&mut self) -> Result<Option<D>, JsonError>where
D: DeserializeOwned,
json only.calls receive and then deserialize