pub struct Replica<C: Crdt> { /* private fields */ }Expand description
Owned state and admitted history. A nonempty initial state need not be reproducible from its initially empty log.
Implementations§
Source§impl<C: Crdt> Replica<C>
impl<C: Crdt> Replica<C>
pub fn new(state: C) -> Self
pub fn state(&self) -> &C
pub fn log(&self) -> &EventLog<C::Delta>
pub fn version(&self) -> &VersionVector
pub fn since(&self, peer: &VersionVector) -> Vec<Record<C::Delta>>where
C::Delta: Clone,
Sourcepub fn admit(&mut self, record: Record<C::Delta>) -> Admission
pub fn admit(&mut self, record: Record<C::Delta>) -> Admission
A Collision verdict also raises the collision alarm; see
Self::collisions and Self::collision_report_bytes.
pub fn append( &mut self, author: u64, delta: C::Delta, ) -> Result<Record<C::Delta>, ReplicaError>
Sourcepub fn inspect_record_bytes(
bytes: &[u8],
limits: CollectionLimits,
) -> Result<Record<C::Delta>, ReplicaError>where
C::Delta: WireDecode,
pub fn inspect_record_bytes(
bytes: &[u8],
limits: CollectionLimits,
) -> Result<Record<C::Delta>, ReplicaError>where
C::Delta: WireDecode,
Decode only; no admission validation or mutation.
pub fn merge_record_bytes( &mut self, bytes: &[u8], limits: CollectionLimits, ) -> Result<Admission, ReplicaError>
Sourcepub fn decode_log_bytes(
&self,
bytes: &[u8],
limits: DecodeLimits,
) -> Result<Vec<Record<C::Delta>>, ReplicaError>
pub fn decode_log_bytes( &self, bytes: &[u8], limits: DecodeLimits, ) -> Result<Vec<Record<C::Delta>>, ReplicaError>
Validate the complete batch and preserve every input occurrence.
pub fn merge_log_bytes( &mut self, bytes: &[u8], limits: DecodeLimits, ) -> Result<Vec<Admission>, ReplicaError>
pub fn log_bytes(&self) -> Result<Vec<u8>, ReplicaError>
Sourcepub fn restore(
state: C,
bytes: &[u8],
limits: DecodeLimits,
) -> Result<Self, ReplicaError>
pub fn restore( state: C, bytes: &[u8], limits: DecodeLimits, ) -> Result<Self, ReplicaError>
Supply a matching empty/bottom state. Publish only a fully checked candidate.
Sourcepub fn collisions(&self) -> Vec<RecordCollision<C::Delta>>where
C::Delta: Clone,
pub fn collisions(&self) -> Vec<RecordCollision<C::Delta>>where
C::Delta: Clone,
Held record IDs a peer holds with a different payload, raised when a
peer’s offer collided here or a peer’s report named one. In memory
only; Self::restore starts with none.
Sourcepub fn collision_report_bytes(&self) -> Result<Option<Vec<u8>>, ReplicaError>
pub fn collision_report_bytes(&self) -> Result<Option<Vec<u8>>, ReplicaError>
The collision report to send back to a peer after merging its batch,
or None when no alarm is raised here.
Sourcepub fn merge_collision_report_bytes(
&mut self,
bytes: &[u8],
limits: DecodeLimits,
) -> Result<Vec<(RecordId, CollisionVerdict)>, ReplicaError>
pub fn merge_collision_report_bytes( &mut self, bytes: &[u8], limits: DecodeLimits, ) -> Result<Vec<(RecordId, CollisionVerdict)>, ReplicaError>
Merge a peer’s collision report; one verdict per entry, in order. Only the alarm can change: never the records, version or state.
Auto Trait Implementations§
impl<C> Freeze for Replica<C>where
C: Freeze,
impl<C> RefUnwindSafe for Replica<C>
impl<C> Send for Replica<C>
impl<C> Sync for Replica<C>
impl<C> Unpin for Replica<C>
impl<C> UnsafeUnpin for Replica<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for Replica<C>
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
Source§fn type_id(&self) -> TypeId
fn type_id(&self) -> TypeId
TypeId of self. Read moreSource§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
Source§fn borrow(&self) -> &T
fn borrow(&self) -> &T
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
Source§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§fn into(self) -> U
fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.