pub struct Sync { /* private fields */ }Expand description
Ditto’s Sync API, obtained via ditto.sync().
Implementations§
Source§impl Sync
impl Sync
Sourcepub fn subscriptions_v2(&self) -> HashSet<SyncSubscription>
pub fn subscriptions_v2(&self) -> HashSet<SyncSubscription>
Returns a snapshot of handles to all active SyncSubscriptions.
Adding or removing SyncSubscriptions from this map will not cause the
underlying subscriptions to be updated.
§Example
let subscription = ditto
.sync()
.register_subscription("SELECT * FROM cars", None)?;
let subscriptions = ditto.sync().subscriptions_v2();
assert!(subscriptions.contains(&subscription));Sourcepub fn register_subscription_v2<Q>(
&self,
query: Q,
) -> Result<Arc<SyncSubscription>, DittoError>
pub fn register_subscription_v2<Q>( &self, query: Q, ) -> Result<Arc<SyncSubscription>, DittoError>
Use a DQL query to subscribe to data on other Ditto peers.
While the subscription is active, data matching this query on other peers will be synced to the local peer’s data store.
Note that dropping the SyncSubscription won’t cancel it, to do that
be sure to use sync_subscription.cancel().
§Example
use dittolive_ditto::prelude::*;
let query = (
"SELECT * FROM cars WHERE color = :color",
serde_json::json!({"color": "blue"}),
);
let sync_subscription = ditto.sync().register_subscription_v2(query)?;
// Cancel the subscription with `.cancel()`
sync_subscription.cancel();Auto Trait Implementations§
impl Freeze for Sync
impl !RefUnwindSafe for Sync
impl Send for Sync
impl Sync for Sync
impl Unpin for Sync
impl !UnwindSafe for Sync
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