pub struct Live;Implementations§
Source§impl Live
impl Live
Sourcepub fn publish<T: Serialize + ?Sized>(
&self,
key: &str,
payload: &T,
) -> Result<()>
pub fn publish<T: Serialize + ?Sized>( &self, key: &str, payload: &T, ) -> Result<()>
Examples found in repository?
examples/heartbeat_daemon.rs (line 48)
33 async fn run(&self, cx: Context) {
34 let _ = cx.events().on("heartbeat.ping");
35 // Answer pings beside the heartbeat loop.
36 let events = cx.clone();
37 cx.spawn(async move {
38 loop {
39 if let Event::Plugin { name, .. } = events.next_event().await
40 && name == "heartbeat.ping"
41 {
42 let _ = events.events().emit("heartbeat.pong", &(), Target::All);
43 }
44 }
45 });
46 loop {
47 self.beats.set(self.beats.get() + 1);
48 let _ = cx.live().publish("heartbeat.beat", &self.beats.get());
49 cx.sleep(30_000).await;
50 }
51 }Sourcepub fn delete(&self, key: &str) -> Result<()>
pub fn delete(&self, key: &str) -> Result<()>
Withdraws the latest value of key: subscribers hear
crate::Event::LiveDeleted (a pane that closed, a machine
that has nothing to report), and later subscribers see nothing.
pub fn subscribe(&self, prefix: &str) -> Result<()>
pub fn unsubscribe(&self, prefix: &str) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Live
impl RefUnwindSafe for Live
impl Send for Live
impl Sync for Live
impl Unpin for Live
impl UnsafeUnpin for Live
impl UnwindSafe for Live
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