Struct chronofold::Chronofold [−][src]
pub struct Chronofold<A, T> { /* fields omitted */ }
Expand description
A conflict-free replicated data structure for versioned sequences.
Terminology
A chronofold can be regarded either as a log of changes or as a sequence of elements. These two viewpoints require distinct terminology:
- A log index is a 0-based index in the log of changes. This indices are stable (i.e. they stay the same after edits), but are subjective for each author.
- An element is a visible (not yet deleted) value of type
T
. - Log order refers to the chronological order in which changes were added to the log. This order is subjective for each author.
- Causal order refers to the order of the linked list.
Editing
You can edit a chronofold in two ways: Either by applying Op
s, or by
creating a Session
which has a Vec
-like API.
Indexing
Like Vec
, the Chronofold
type allows to access values by index,
because it implements the Index
trait. The same rules apply:
out-of-bound indexes cause panics, and you can use get
to check whether
the index exists.
Implementations
Returns the index of the last log entry (in log order).
Returns an iterator over elements and their log indices in causal order.
Returns an iterator over elements and their log indices in causal order.
Returns an iterator over elements in causal order.
Returns an iterator over changes in log order.
pub fn iter_ops<'a, R, V>(&'a self, range: R) -> Ops<'a, A, T, V>ⓘ where
R: RangeBounds<LogIndex> + 'a,
V: FromLocalValue<'a, A, T>,
pub fn iter_ops<'a, R, V>(&'a self, range: R) -> Ops<'a, A, T, V>ⓘ where
R: RangeBounds<LogIndex> + 'a,
V: FromLocalValue<'a, A, T>,
Returns an iterator over ops in log order.
Returns a vector clock representing the version of this chronofold.
pub fn iter_newer_ops<'a, V>(
&'a self,
version: &'a Version<A>
) -> impl Iterator<Item = Op<A, V>> + 'a where
V: FromLocalValue<'a, A, T> + 'a,
pub fn iter_newer_ops<'a, V>(
&'a self,
version: &'a Version<A>
) -> impl Iterator<Item = Op<A, V>> + 'a where
V: FromLocalValue<'a, A, T> + 'a,
Returns an iterator over ops newer than the given version in log order.
Returns a reference to a change in the chronofold’s log.
If index
is out of bounds, None
is returned.
Creates an editing session for a single author.
pub fn apply<V>(&mut self, op: Op<A, V>) -> Result<(), ChronofoldError<A, V>> where
V: IntoLocalValue<A, T>,
pub fn apply<V>(&mut self, op: Op<A, V>) -> Result<(), ChronofoldError<A, V>> where
V: IntoLocalValue<A, T>,
Applies an op to the chronofold.
Trait Implementations
Performs the conversion.
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl<A, T> RefUnwindSafe for Chronofold<A, T> where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<A, T> Send for Chronofold<A, T> where
A: Send,
T: Send,
impl<A, T> Sync for Chronofold<A, T> where
A: Sync,
T: Sync,
impl<A, T> Unpin for Chronofold<A, T> where
T: Unpin,
impl<A, T> UnwindSafe for Chronofold<A, T> where
A: RefUnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more