[][src]Struct chronofold::Chronofold

pub struct Chronofold<A: Author, T> { /* fields omitted */ }

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 Ops, 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

impl<A: Author, T> Chronofold<A, T>[src]

pub fn last_index(&self) -> Option<LogIndex>[src]

Returns the index of the last log entry (in log order).

impl<A: Author, T> Chronofold<A, T>[src]

pub fn iter(&self) -> impl Iterator<Item = (&T, LogIndex)>[src]

Returns an iterator over elements and their log indices in causal order.

pub fn iter_range<R>(&self, range: R) -> impl Iterator<Item = (&T, LogIndex)> where
    R: RangeBounds<LogIndex>, 
[src]

Returns an iterator over elements and their log indices in causal order.

pub fn iter_elements(&self) -> impl Iterator<Item = &T>[src]

Returns an iterator over elements in causal order.

pub fn iter_changes(&self) -> impl Iterator<Item = &Change<T>>[src]

Returns an iterator over changes in log order.

impl<A: Author, T: Clone> Chronofold<A, T>[src]

pub fn iter_ops<'a, R>(
    &'a self,
    range: R
) -> impl Iterator<Item = Op<A, T>> + 'a where
    R: RangeBounds<LogIndex> + 'a, 
[src]

Returns an iterator over ops in log order.

impl<A: Author, T: Clone> Chronofold<A, T>[src]

pub fn version(&self) -> &Version<A>[src]

Returns a vector clock representing the version of this chronofold.

pub fn iter_newer_ops<'a>(
    &'a self,
    version: &'a Version<A>
) -> impl Iterator<Item = Op<A, T>> + 'a
[src]

Returns an iterator over ops newer than the given version in log order.

impl<A: Author, T: Debug> Chronofold<A, T>[src]

pub fn new() -> Self[src]

Constructs a new, empty chronofold.

pub fn session(&mut self, author: A) -> Session<A, T>[src]

Creates an editing session for a single author.

pub fn apply(&mut self, op: Op<A, T>) -> Result<(), ChronofoldError<A, T>>[src]

Applies an op to the chronofold.

pub fn is_empty(&self) -> bool[src]

Returns true if the chronofold contains no elements.

pub fn len(&self) -> usize[src]

Returns the number of elements in the chronofold.

pub fn get(&self, index: LogIndex) -> Option<&Change<T>>[src]

Returns a reference to a change in the chronofold's log.

If index is out of bounds, None is returned.

Trait Implementations

impl<'_, A: Author, T> AsMut<Chronofold<A, T>> for Session<'_, A, T>[src]

impl<'_, A: Author, T> AsRef<Chronofold<A, T>> for Session<'_, A, T>[src]

impl<A: Clone + Author, T: Clone> Clone for Chronofold<A, T>[src]

impl<A: Debug + Author, T: Debug> Debug for Chronofold<A, T>[src]

impl<A: Author, T> Default for Chronofold<A, T>[src]

impl<A: Author, T: Display> Display for Chronofold<A, T>[src]

impl<A: Eq + Author, T: Eq> Eq for Chronofold<A, T>[src]

impl<A: Author, T> Index<LogIndex> for Chronofold<A, T>[src]

type Output = Change<T>

The returned type after indexing.

impl<A: PartialEq + Author, T: PartialEq> PartialEq<Chronofold<A, T>> for Chronofold<A, T>[src]

impl<A: Author, T> StructuralEq for Chronofold<A, T>[src]

impl<A: Author, T> StructuralPartialEq for Chronofold<A, T>[src]

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
    A: Unpin,
    T: Unpin

impl<A, T> UnwindSafe for Chronofold<A, T> where
    A: RefUnwindSafe + UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.