Struct chronofold::Session [−][src]
pub struct Session<'a, A, T> { /* fields omitted */ }
Expand description
An editing session tied to one author.
Session
provides a lot of functions you might know from Vec
or
VecDeque
. Under the hood, Session
will append changes to the
chronofolds log.
Note that Session
has a mutable (exclusive) borrow of a chronofold. So
Rust’s ownership rules enforce that there is always just one Session
per
chronofold.
Implementations
Creates an editing session for a single author.
Appends an element to the back of the chronofold and returns the new element’s log index.
Prepends an element to the chronofold and returns the new element’s log index.
Inserts an element after the element with log index index
and returns
the new element’s log index.
If index == None
, the element will be inserted at the beginning.
Removes the element with log index index
from the chronofold.
Note that this just marks the element as deleted, not actually modify
the log apart from appending a Change::Delete
.
Extends the chronofold with the contents of iter
, returns the log
index of the last inserted element, if any.
pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Option<LogIndex> where
I: IntoIterator<Item = T>,
R: RangeBounds<LogIndex>,
pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Option<LogIndex> where
I: IntoIterator<Item = T>,
R: RangeBounds<LogIndex>,
Replaces the specified range in the chronofold with the given
replace_with
iterator and returns the log index of the last inserted
element, if any.
pub fn iter_ops<V>(&'a self) -> impl Iterator<Item = Op<A, V>> + 'a where
V: FromLocalValue<'a, A, T> + 'a,
pub fn iter_ops<V>(&'a self) -> impl Iterator<Item = Op<A, V>> + 'a where
V: FromLocalValue<'a, A, T> + 'a,
Returns an iterator over ops in log order, that where created in this session.
Trait Implementations
Performs the conversion.
Performs the conversion.