dittolive-ditto 4.3.1

Ditto is a peer to peer cross-platform database that allows mobile, web, IoT and server apps to sync with or without an internet connection.
Documentation
use_prelude!();
use std::sync::{Arc, Weak};

use super::{v2::V2Presence, v3::Peer};

/// A token returned by `Presence::observe`. Retain this object to continue
/// receiving callback updates.
pub struct OnConnect {
    _ctx: Arc<OnConnectCtx>,
}

pub(crate) type WeakOnConnect = Weak<OnConnectCtx>;

impl OnConnect {
    pub(crate) fn new(_ctx: Arc<OnConnectCtx>) -> Self {
        Self { _ctx }
    }
}

impl Observer for OnConnect {}

pub(crate) struct OnConnectCtx {
    pub(crate) on_presence: Box<dyn Fn(&Peer) + Send + Sync + 'static>,
}

impl OnConnectCtx {
    pub(crate) fn new(on_presence: Box<dyn Fn(&Peer) + Send + Sync + 'static>) -> Self {
        Self { on_presence }
    }
}