pub struct DeltaReplica<S: Lattice, D: Lattice = S> {
pub id: ReplicaId,
/* private fields */
}Expand description
A delta-CRDT replica implementing Algorithm 1
Fields§
§id: ReplicaIdReplica identifier
Implementations§
Source§impl<S: Lattice, D: Lattice> DeltaReplica<S, D>
impl<S: Lattice, D: Lattice> DeltaReplica<S, D>
Sourcepub fn with_buffer_size(id: impl Into<ReplicaId>, buffer_size: usize) -> Self
pub fn with_buffer_size(id: impl Into<ReplicaId>, buffer_size: usize) -> Self
Create a new replica with specified buffer size
Sourcepub fn buffer(&self) -> &DeltaBuffer<D>
pub fn buffer(&self) -> &DeltaBuffer<D>
Get mutable access to buffer
Sourcepub fn register_peer(&mut self, peer_id: ReplicaId)
pub fn register_peer(&mut self, peer_id: ReplicaId)
Register a peer for anti-entropy
Sourcepub fn current_seq(&self) -> SeqNo
pub fn current_seq(&self) -> SeqNo
Current sequence number
Source§impl<S: Lattice + Clone> DeltaReplica<S, S>
Delta-CRDT replica where state and delta are the same type
impl<S: Lattice + Clone> DeltaReplica<S, S>
Delta-CRDT replica where state and delta are the same type
Sourcepub fn mutate<F>(&mut self, mutator: F) -> S
pub fn mutate<F>(&mut self, mutator: F) -> S
Apply a delta-mutator: computes delta, applies to state, buffers delta Returns the computed delta
Sourcepub fn prepare_sync(&self, peer_id: &str) -> Option<(S, SeqNo)>
pub fn prepare_sync(&self, peer_id: &str) -> Option<(S, SeqNo)>
Get delta-group to send to a peer
Sourcepub fn receive_delta(&mut self, delta: &S)
pub fn receive_delta(&mut self, delta: &S)
Receive and apply a delta from a peer (idempotent!)
Sourcepub fn process_ack(&mut self, peer_id: &str, seq: SeqNo)
pub fn process_ack(&mut self, peer_id: &str, seq: SeqNo)
Process an ack from a peer
Sourcepub fn full_state(&self) -> &S
pub fn full_state(&self) -> &S
Full state (for initial sync or recovery)
Sourcepub fn sync_with(&mut self, other: &mut DeltaReplica<S, S>)
pub fn sync_with(&mut self, other: &mut DeltaReplica<S, S>)
Sync with another replica directly (for testing/simulation)
Trait Implementations§
Auto Trait Implementations§
impl<S, D> Freeze for DeltaReplica<S, D>where
S: Freeze,
impl<S, D> RefUnwindSafe for DeltaReplica<S, D>where
S: RefUnwindSafe,
D: RefUnwindSafe,
impl<S, D> Send for DeltaReplica<S, D>
impl<S, D> Sync for DeltaReplica<S, D>
impl<S, D> Unpin for DeltaReplica<S, D>
impl<S, D> UnwindSafe for DeltaReplica<S, D>where
S: UnwindSafe,
D: UnwindSafe,
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