Skip to main content

Replica

Struct Replica 

Source
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>

Source

pub fn new(state: C) -> Self

Source

pub fn state(&self) -> &C

Source

pub fn log(&self) -> &EventLog<C::Delta>

Source

pub fn version(&self) -> &VersionVector

Source

pub fn since(&self, peer: &VersionVector) -> Vec<Record<C::Delta>>
where C::Delta: Clone,

Source

pub fn admit(&mut self, record: Record<C::Delta>) -> Admission
where C::Delta: Clone + PartialEq,

A Collision verdict also raises the collision alarm; see Self::collisions and Self::collision_report_bytes.

Source

pub fn append( &mut self, author: u64, delta: C::Delta, ) -> Result<Record<C::Delta>, ReplicaError>
where C::Delta: Clone + PartialEq,

Source

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.

Source

pub fn merge_record_bytes( &mut self, bytes: &[u8], limits: CollectionLimits, ) -> Result<Admission, ReplicaError>
where C::Delta: Clone + PartialEq + WireDecode,

Source

pub fn decode_log_bytes( &self, bytes: &[u8], limits: DecodeLimits, ) -> Result<Vec<Record<C::Delta>>, ReplicaError>
where C::Delta: Clone + PartialEq + WireDecode + WireSchema,

Validate the complete batch and preserve every input occurrence.

Source

pub fn merge_log_bytes( &mut self, bytes: &[u8], limits: DecodeLimits, ) -> Result<Vec<Admission>, ReplicaError>
where C::Delta: Clone + PartialEq + WireDecode + WireSchema,

Source

pub fn log_bytes(&self) -> Result<Vec<u8>, ReplicaError>

Source

pub fn restore( state: C, bytes: &[u8], limits: DecodeLimits, ) -> Result<Self, ReplicaError>
where C::Delta: Clone + PartialEq + WireDecode + WireSchema,

Supply a matching empty/bottom state. Publish only a fully checked candidate.

Source

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.

Source

pub fn collision_report_bytes(&self) -> Result<Option<Vec<u8>>, ReplicaError>
where C::Delta: Clone + WireEncode + WireSchema,

The collision report to send back to a peer after merging its batch, or None when no alarm is raised here.

Source

pub fn merge_collision_report_bytes( &mut self, bytes: &[u8], limits: DecodeLimits, ) -> Result<Vec<(RecordId, CollisionVerdict)>, ReplicaError>
where C::Delta: PartialEq + WireDecode + WireSchema,

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>
where C: RefUnwindSafe, <C as Crdt>::Delta: RefUnwindSafe,

§

impl<C> Send for Replica<C>
where C: Send, <C as Crdt>::Delta: Send,

§

impl<C> Sync for Replica<C>
where C: Sync, <C as Crdt>::Delta: Sync,

§

impl<C> Unpin for Replica<C>
where C: Unpin, <C as Crdt>::Delta: Unpin,

§

impl<C> UnsafeUnpin for Replica<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for Replica<C>
where C: UnwindSafe, <C as Crdt>::Delta: RefUnwindSafe + UnwindSafe,

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.