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>
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
Trait Implementations§
Source§impl<'a> Extractor<'a, WebSocket> for WebSocket
impl<'a> Extractor<'a, WebSocket> for WebSocket
type Error = Infallible
type Prepared = ()
fn validate(_validate: Validate<'_>)
fn prepare( _prepare: Prepare<'_>, ) -> Pin<Box<dyn Future<Output = Result<Self::Prepared, Self::Error>> + Send + '_>>
fn extract(
extract: Extract<'a, '_, Self::Prepared, WebSocket>,
) -> Result<Self, Self::Error>where
Self: Sized,
Auto Trait Implementations§
impl !Freeze for WebSocket
impl !RefUnwindSafe for WebSocket
impl Send for WebSocket
impl !Sync for WebSocket
impl Unpin 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