Struct dittolive_ditto::prelude::Presence
source · pub struct Presence { /* private fields */ }
Expand description
Presence
to visualize the mesh.
Even if Ditto works as a standalone, other peers are needed to exploit it at its maximum extend : syncing data and merging it.
The Presence
struct allows you to get and monitor known peers.
The peers are regrouped inside a PresenceGraph
.
You can get Presence
using the Ditto::presence
method.
To have an immediate graph of peers, use Presence::exec
:
let presence_graph = ditto.presence().exec();
To monitor peers, use Presence::observe
to call a callback each time peers are updated:
let handle = ditto.presence().observe(|presence_graph| {
// Do something with peers
});
Implementations§
source§impl Presence
impl Presence
sourcepub fn observe(
self: &Arc<Self>,
callback: impl Fn(&PresenceGraph) + Send + Sync + 'static
) -> PresenceObserver
pub fn observe( self: &Arc<Self>, callback: impl Fn(&PresenceGraph) + Send + Sync + 'static ) -> PresenceObserver
Allow to call a callback each time there is a change in known peers.
The returned PresenceObserver
must be kept in scope to keep receiving updates.
sourcepub fn exec(&self) -> PresenceGraph
pub fn exec(&self) -> PresenceGraph
Return an immediate representation of known peers
Auto Trait Implementations§
impl RefUnwindSafe for Presence
impl Send for Presence
impl Sync for Presence
impl Unpin for Presence
impl UnwindSafe for Presence
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