pub struct CrdtConfig {
pub strategy: MergeStrategy,
pub delete_policy: DeletePolicy,
pub timestamp_extractor: Option<TimestampExtractor>,
}Expand description
Configuration for conflict-free merging.
Controls how the CRDT merger resolves conflicts between concurrent modifications.
§Example
use prolly::{CrdtConfig, MergeStrategy, DeletePolicy};
let config = CrdtConfig {
strategy: MergeStrategy::LastWriterWins,
delete_policy: DeletePolicy::UpdateWins,
timestamp_extractor: None,
};Fields§
§strategy: MergeStrategyThe merge strategy to use for resolving conflicts.
delete_policy: DeletePolicyPolicy for delete vs update conflicts.
timestamp_extractor: Option<TimestampExtractor>Function to extract timestamp from value (for LWW).
If None, values are assumed to be in TimestampedValue format.
If extraction fails, timestamp defaults to 0.
Implementations§
Source§impl CrdtConfig
impl CrdtConfig
Sourcepub fn multi_value() -> Self
pub fn multi_value() -> Self
Create a new CrdtConfig with MV strategy.
Sourcepub fn custom<F>(merge_fn: F) -> Self
pub fn custom<F>(merge_fn: F) -> Self
Create a new CrdtConfig with a custom merge function.
The callback must be pure and deterministic and may be invoked more than once for a conflict while the engine changes execution paths.
Sourcepub fn with_delete_policy(self, policy: DeletePolicy) -> Self
pub fn with_delete_policy(self, policy: DeletePolicy) -> Self
Set the delete policy.
Trait Implementations§
Source§impl Clone for CrdtConfig
impl Clone for CrdtConfig
Source§fn clone(&self) -> CrdtConfig
fn clone(&self) -> CrdtConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CrdtConfig
impl Debug for CrdtConfig
Auto Trait Implementations§
impl !RefUnwindSafe for CrdtConfig
impl !UnwindSafe for CrdtConfig
impl Freeze for CrdtConfig
impl Send for CrdtConfig
impl Sync for CrdtConfig
impl Unpin for CrdtConfig
impl UnsafeUnpin for CrdtConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more