Sync

Struct Sync 

Source
pub struct Sync { /* private fields */ }
Expand description

Implementations§

Source§

impl Sync

Source

pub fn subscriptions(&self) -> HashSet<SyncSubscription>

Returns a snapshot of handles to all active SyncSubscriptions.

Adding or removing SyncSubscriptions from this set will not cause the underlying subscriptions to be updated.

§Example
let subscription = ditto.sync().register_subscription("SELECT * FROM cars")?;
let subscriptions = ditto.sync().subscriptions();
assert!(subscriptions.contains(&subscription));
Source

pub fn register_subscription<Q>( &self, query: Q, ) -> Result<Arc<SyncSubscription>, DittoError>
where Q: IntoQuery, Q::Args: Serialize,

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(query)?;

// Cancel the subscription with `.cancel()`
sync_subscription.cancel();
Source

pub fn start(&self) -> Result<(), DittoError>

Start syncing on all transports.

By default, Ditto will enable all peer-to-peer transport types. The network configuration can be customized using Ditto::set_transport_config.

§Example
ditto.sync().start()?;
§Errors

Returns an error if the Ditto instance has not been activated with a valid license.

Source

pub fn stop(&self)

Stop syncing on all transports.

You may continue to use the Ditto store locally but no data will sync to or from other devices.

§Example
ditto.sync().stop();
Source

pub fn is_active(&self) -> bool

Returns true if sync is currently active, otherwise returns false.

Use ditto.sync().start() to activate and ditto.sync().stop() to deactivate sync.

§Example
if ditto.sync().is_active() {
    println!("Sync is active");
}

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

impl<T> FitForCArc for T

§

type CArcWrapped = ThinArc<T>

§

impl<T> FitForCBox for T

§

type CBoxWrapped = ThinBox<T>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

§

impl<T> To for T
where T: ?Sized,

§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<F> ZeroSizedElseWrathOfTheGඞds for F