pub struct WsSink(/* private fields */);Expand description
A clonable handle for sending messages over a WebSocket connection.
Clones share the codec state. The sink is also the connection’s codec, so the dispatcher and all sinks see the same state, e.g. once a close message is sent by either of them, no more messages can be sent.
Implementations§
Source§impl WsSink
impl WsSink
Sourcepub async fn send(&self, item: Message) -> Result<(), ProtocolError>
pub async fn send(&self, item: Message) -> Result<(), ProtocolError>
Encodes and queues a message for the peer.
Data messages (text, binary and continuation) wait while write back-pressure is enabled, until the write buffer can accept more output. Control messages are queued immediately.
Sending a close message starts the closing handshake. The connection remains open for the peer’s close response and is shut down when the configured closing-handshake timeout expires.
Sourcepub fn on_disconnect(&self) -> Waiter<'static> ⓘ
pub fn on_disconnect(&self) -> Waiter<'static> ⓘ
Returns a future that resolves when the connection is disconnected.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WsSink
impl !Send for WsSink
impl !Sync for WsSink
impl !UnwindSafe for WsSink
impl Freeze for WsSink
impl Unpin for WsSink
impl UnsafeUnpin for WsSink
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