[−][src]Struct chronofold::Chronofold
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
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]
R: RangeBounds<LogIndex>,
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]
&'a self,
range: R
) -> impl Iterator<Item = Op<A, T>> + 'a where
R: RangeBounds<LogIndex> + 'a,
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]
&'a self,
version: &'a Version<A>
) -> impl Iterator<Item = Op<A, T>> + 'a
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]
fn as_mut(&mut self) -> &mut Chronofold<A, T>
[src]
impl<'_, A: Author, T> AsRef<Chronofold<A, T>> for Session<'_, A, T>
[src]
fn as_ref(&self) -> &Chronofold<A, T>
[src]
impl<A: Clone + Author, T: Clone> Clone for Chronofold<A, T>
[src]
fn clone(&self) -> Chronofold<A, T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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.
fn index(&self, index: LogIndex) -> &Self::Output
[src]
impl<A: PartialEq + Author, T: PartialEq> PartialEq<Chronofold<A, T>> for Chronofold<A, T>
[src]
fn eq(&self, other: &Chronofold<A, T>) -> bool
[src]
fn ne(&self, other: &Chronofold<A, T>) -> bool
[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,
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<A, T> Send for Chronofold<A, T> where
A: Send,
T: Send,
A: Send,
T: Send,
impl<A, T> Sync for Chronofold<A, T> where
A: Sync,
T: Sync,
A: Sync,
T: Sync,
impl<A, T> Unpin for Chronofold<A, T> where
A: Unpin,
T: Unpin,
A: Unpin,
T: Unpin,
impl<A, T> UnwindSafe for Chronofold<A, T> where
A: RefUnwindSafe + UnwindSafe,
T: UnwindSafe,
A: RefUnwindSafe + UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,