pub struct WebSocket { /* private fields */ }Expand description
An open WebSocket. Read it with WebSocket::next or WebSocket::read_async, and send
through it or a WsSender. Dropping it closes the connection with code 1000.
Implementations§
Source§impl WebSocket
impl WebSocket
Sourcepub fn sender(&self) -> WsSender
pub fn sender(&self) -> WsSender
A sending half to give to other code: it can send, ping and close.
Sourcepub fn send_async(
&self,
message: Message,
done: impl FnOnce(Result<(), HttpError>) + Send + 'static,
)
pub fn send_async( &self, message: Message, done: impl FnOnce(Result<(), HttpError>) + Send + 'static, )
Send a message; done reports when the platform took it.
Sourcepub fn send_future(&self, message: Message) -> Oneshot<Result<(), HttpError>> ⓘ
pub fn send_future(&self, message: Message) -> Oneshot<Result<(), HttpError>> ⓘ
Send a message and await the platform taking it.
Sourcepub fn next(&mut self) -> NextMessage<'_> ⓘ
pub fn next(&mut self) -> NextMessage<'_> ⓘ
The next message; the last is a Message::Close, then None.
Trait Implementations§
Auto Trait Implementations§
impl Forget for WebSocket
impl Freeze for WebSocket
impl Move 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