Struct dittolive_ditto::sync::Sync
source · pub struct Sync { /* private fields */ }
Expand description
Ditto’s Sync
API, obtained via ditto.sync()
.
Implementations§
source§impl Sync
impl Sync
sourcepub fn subscriptions(
&self,
) -> impl '_ + Deref<Target = SetArc<SyncSubscription>>
pub fn subscriptions( &self, ) -> impl '_ + Deref<Target = SetArc<SyncSubscription>>
Gets temporary access to the set of currently registered subscriptions.
A (read) lock is held until the return value is dropped: this means
that neither Self::register_subscription()
nor
SyncSubscription::cancel()
can make progress until this read
lock is released.
sourcepub fn register_subscription<Q>(
&self,
query: Q,
query_args: Option<QueryArguments>,
) -> Result<Arc<SyncSubscription>, DittoError>
pub fn register_subscription<Q>( &self, query: Q, query_args: Option<QueryArguments>, ) -> 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 sync_subscription = ditto.sync().register_subscription(
"SELECT * FROM cars WHERE color = :color",
Some(serde_json::json!({
"color": "blue"
}).into()),
)?;
// 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