pub struct Sender { /* private fields */ }
Expand description
Sends JSON objects over a realtime stream to a single connected client
You almost certainly will only use a Sender
inside of a Channel
.
Implementations§
Source§impl Sender
impl Sender
Sourcepub fn send<S: Into<String>>(
&mut self,
event_type: S,
val: JsonObject,
) -> Result<(), ()>
pub fn send<S: Into<String>>( &mut self, event_type: S, val: JsonObject, ) -> Result<(), ()>
Sends the object val
to the client connected to this Sender
.
event_type
is some sort of event type, like "post"
or "delete"
, but it can be whatever
you’d like. The Result
returned is Ok(())
if the send was successful, and Err(())
if the
send was a failure. Note that this function returns instantly; the messages are queued in memory
before being sent out to the client.
Auto Trait Implementations§
impl Freeze for Sender
impl !RefUnwindSafe for Sender
impl Send for Sender
impl Sync for Sender
impl Unpin 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