pub struct EventLog<D> { /* private fields */ }Expand description
Append-only, deduplicating event log for CRDT deltas.
Implementations§
Source§impl<D> EventLog<D>
impl<D> EventLog<D>
pub fn new() -> Self
Sourcepub fn with_replica_count(replica_count: usize) -> Self
pub fn with_replica_count(replica_count: usize) -> Self
Create a log for a fixed replica domain, including an empty domain.
Sourcepub fn for_crdt<C: Crdt<Delta = D>>(state: &C) -> Self
pub fn for_crdt<C: Crdt<Delta = D>>(state: &C) -> Self
Bind persistence metadata to the CRDT’s actual domain before recording.
pub fn replica_count(&self) -> Option<usize>
pub fn append(&mut self, replica: u64, delta: D) -> RecordIdwhere
D: PartialEq,
Sourcepub fn append_with<F>(
&mut self,
replica: u64,
delta: D,
apply: F,
) -> Result<RecordId, AppendError>where
D: PartialEq,
F: FnOnce(&D),
pub fn append_with<F>(
&mut self,
replica: u64,
delta: D,
apply: F,
) -> Result<RecordId, AppendError>where
D: PartialEq,
F: FnOnce(&D),
Allocate a fresh ID, then use the same gate as incoming records.
pub fn merge_records<I>(&mut self, records: I) -> Vec<Admission>
Sourcepub fn admit_with<F>(&mut self, record: Record<D>, apply: F) -> Admissionwhere
D: PartialEq,
F: FnOnce(&D),
pub fn admit_with<F>(&mut self, record: Record<D>, apply: F) -> Admissionwhere
D: PartialEq,
F: FnOnce(&D),
The sole record admission decision. Only Accepted invokes apply.
The callback must be infallible and use the same delta interpretation as
replay. This is an in-memory transition, not a crash-durability guarantee.
pub fn version(&self) -> &VersionVector
pub fn records(&self) -> &[Record<D>]
pub fn insert_record(&mut self, record: Record<D>) -> Admissionwhere
D: PartialEq,
Source§impl<D: Clone> EventLog<D>
impl<D: Clone> EventLog<D>
pub fn since(&self, version: &VersionVector) -> Vec<Record<D>>
Source§impl<D: WireDecode + WireSchema + PartialEq> EventLog<D>
impl<D: WireDecode + WireSchema + PartialEq> EventLog<D>
Sourcepub fn from_wire_bytes_for<C: Crdt<Delta = D>>(
bytes: &[u8],
state: &C,
) -> Result<Self, WireError>
pub fn from_wire_bytes_for<C: Crdt<Delta = D>>( bytes: &[u8], state: &C, ) -> Result<Self, WireError>
Decode and compare the saved shape with the destination before replay.
Plain from_wire_bytes decodes a log and retains its domain; it does not
load a CRDT. Use this method at every persisted-state loading boundary.
Trait Implementations§
impl<D: Eq> Eq for EventLog<D>
Source§impl<D: PartialEq> PartialEq for EventLog<D>
impl<D: PartialEq> PartialEq for EventLog<D>
Source§fn eq(&self, other: &EventLog<D>) -> bool
fn eq(&self, other: &EventLog<D>) -> bool
self and other values to be equal, and is used by ==.1.0.0 (const: unstable) · Source§fn ne(&self, other: &Rhs) -> bool
fn ne(&self, other: &Rhs) -> bool
!=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.impl<D: PartialEq> StructuralPartialEq for EventLog<D>
Source§impl<D: WireDecode + WireSchema + PartialEq> WireDecode for EventLog<D>
impl<D: WireDecode + WireSchema + PartialEq> WireDecode for EventLog<D>
fn decode_wire(cursor: &mut WireCursor<'_>) -> Result<Self, WireError>
fn from_wire_bytes(bytes: &[u8]) -> Result<Self, WireError>
Source§impl<D: WireEncode + WireSchema> WireEncode for EventLog<D>
impl<D: WireEncode + WireSchema> WireEncode for EventLog<D>
fn encode_wire(&self, out: &mut Vec<u8>) -> Result<(), WireError>
fn to_wire_bytes(&self) -> Result<Vec<u8>, WireError>
Source§impl<D: WireSchema> WireSchema for EventLog<D>
impl<D: WireSchema> WireSchema for EventLog<D>
fn wire_schema() -> Vec<u8> ⓘ
const REQUIRES_ARITY: bool = false
Auto Trait Implementations§
impl<D> Freeze for EventLog<D>
impl<D> RefUnwindSafe for EventLog<D>where
D: RefUnwindSafe,
impl<D> Send for EventLog<D>where
D: Send,
impl<D> Sync for EventLog<D>where
D: Sync,
impl<D> Unpin for EventLog<D>where
D: Unpin,
impl<D> UnsafeUnpin for EventLog<D>
impl<D> UnwindSafe for EventLog<D>where
D: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)self to dest. Read moreSource§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.