Struct dittolive_ditto::transport::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
sourceimpl 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> CompatExt for T
impl<T> CompatExt for T
fn compat_ref(&self) -> Compat<&T>
fn compat_ref(&self) -> Compat<&T>
Applies the [
Compat
] adapter by shared reference. Read morefn compat_mut(&mut self) -> Compat<&mut T>
fn compat_mut(&mut self) -> Compat<&mut T>
Applies the [
Compat
] adapter by mutable reference. Read more