pub struct Sender { /* private fields */ }Expand description
A cloneable handle for pushing messages at one client.
Handed to the broadcaster, to background tasks, to anything that produces events. It never blocks the reader, and it can outlive the socket: once the connection is gone every clone reports closed.
Implementations§
Source§impl Sender
impl Sender
Sourcepub async fn send(&self, message: impl Into<Message>) -> WsResult<()>
pub async fn send(&self, message: impl Into<Message>) -> WsResult<()>
Queue a message, waiting for room. Use this from the connection’s own task, where waiting is what you want.
Sourcepub fn try_send(&self, message: impl Into<Message>) -> WsResult<()>
pub fn try_send(&self, message: impl Into<Message>) -> WsResult<()>
Queue a message only if there is room right now.
This is the shape broadcasting needs: fan-out must never wait on the slowest subscriber, so a full queue is a failure the caller acts on by dropping the subscriber.
pub fn is_closed(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sender
impl RefUnwindSafe for Sender
impl Send for Sender
impl Sync for Sender
impl Unpin for Sender
impl UnsafeUnpin for Sender
impl UnwindSafe for Sender
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