Struct dittolive_ditto::ditto::Ditto
source · [−]pub struct Ditto { /* private fields */ }
Expand description
The entry point for accessing Ditto-related functionality This struct is generally a handle and interface to ditto-functionality which operates in background threads.
Implementations
sourceimpl Ditto
impl Ditto
sourcepub fn start_sync(&self) -> Result<(), DittoError>
pub fn start_sync(&self) -> Result<(), DittoError>
Start syncing on all configured transports
sourcepub fn set_transport_config(&self, config: TransportConfig)
pub fn set_transport_config(&self, config: TransportConfig)
Set a new TransportConfig
and being syncing over these transports
Any change to start or stop a specific transport should proceed via
providing a modified configuration to this method
sourcepub fn current_transport_config(&self) -> Result<TransportConfig, DittoError>
pub fn current_transport_config(&self) -> Result<TransportConfig, DittoError>
Returns a snapshot of the currently configured transports
sourceimpl Ditto
impl Ditto
pub fn set_logging_enabled(enabled: bool)
pub fn get_logging_enabled() -> bool
pub fn get_emoji_log_level_headings_enabled() -> bool
pub fn set_emoji_log_level_headings_enabled(enabled: bool)
pub fn get_minimum_log_level() -> LogLevel
pub fn set_minimum_log_level(log_level: LogLevel)
sourceimpl Ditto
impl Ditto
sourcepub fn set_offline_only_license_token(
&self,
license_token: &str
) -> Result<(), DittoError>
pub fn set_offline_only_license_token(
&self,
license_token: &str
) -> Result<(), DittoError>
Activate an offline Ditto instance by setting a license token. You cannot initiate sync on an offline (Development, OfflinePlayground, Manual or SharedKey) Ditto instance before you have activated it.
sourcepub fn set_license_from_env(&self, var_name: &str) -> Result<(), DittoError>
pub fn set_license_from_env(&self, var_name: &str) -> Result<(), DittoError>
Look for a license token from a given environment variable
sourcepub fn site_id(&self) -> u64
pub fn site_id(&self) -> u64
Returns the site ID that the instance of Ditto is using as part of its identity.
sourcepub fn set_device_name(&self, name: &str)
pub fn set_device_name(&self, name: &str)
Set a custom identifier for the current device
When using observePeers(), each remote peer is represented by a short UTF-8 “device name”. By default this will be a truncated version of the device’s hostname. It does not need to be unique among peers. Configure the device name before calling start(). If it is too long it will be truncated.
sourcepub fn transport_diagnostics(&self) -> TransportDiagnostics
pub fn transport_diagnostics(&self) -> TransportDiagnostics
Request bulk status information about the transports. This is mostly intended for statistical or debugging purposes.
sourcepub fn observe_peers_v2<H>(&self, handler: H) -> PeersObserver where
H: Fn(V2Presence) + Send + Sync + 'static,
👎 Deprecated: use observe_peers instead
pub fn observe_peers_v2<H>(&self, handler: H) -> PeersObserver where
H: Fn(V2Presence) + Send + Sync + 'static,
use observe_peers instead
Request information about Ditto peers in range of this device.
This method returns an observer which should be held as long as updates are required. A newly registered observer will have a peers update delivered to it immediately. Then it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change.
sourcepub fn observe_peers<H>(&self, handler: H) -> PeersObserver where
H: Fn(V2Presence) + Send + Sync + 'static,
pub fn observe_peers<H>(&self, handler: H) -> PeersObserver where
H: Fn(V2Presence) + Send + Sync + 'static,
Request information about Ditto peers in range of this device.
This method returns an observer which should be held as long as updates are required. A newly registered observer will have a peers update delivered to it immediately. Then it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change.
pub fn root_dir(&self) -> &Path
pub fn data_dir(&self) -> &Path
pub fn authenticator(&self) -> Option<DittoAuthenticator>
sourcepub fn is_activated(&self) -> bool
pub fn is_activated(&self) -> bool
Has this Ditto instance been activated yet with a valid license token
sourceimpl Ditto
impl Ditto
sourcepub fn builder() -> DittoBuilder
pub fn builder() -> DittoBuilder
Returns a builder for Ditto following the builder pattern Start constructing a new Ditto instance
sourceimpl Ditto
impl Ditto
sourcepub fn run_garbage_collection(&self)
pub fn run_garbage_collection(&self)
Removes all sync metadata for any remote peers which aren’t currently connected. This method shouldn’t usually be called. Manually running garbage collection often will result in slower sync times. Ditto automatically runs a garbage a collection process in the background at optimal times.
Manually running garbage collection is typically only useful during testing if large amounts of data are being generated. Alternatively, if an entire data set is to be evicted and it’s clear that maintaining this metadata isn’t necessary, then garbage collection could be run after evicting the old data.
Trait Implementations
sourceimpl Deref for Ditto
impl Deref for Ditto
type Target = DittoFields
type Target = DittoFields
The resulting type after dereferencing.
sourcefn deref(&self) -> &DittoFields
fn deref(&self) -> &DittoFields
Dereferences the value.
Auto Trait Implementations
impl !RefUnwindSafe for Ditto
impl Send for Ditto
impl Sync for Ditto
impl Unpin for Ditto
impl !UnwindSafe for Ditto
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more