pub struct Session<'a, A, T> { /* private fields */ }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§
Source§impl<'a, A: Author, T> Session<'a, A, T>
impl<'a, A: Author, T> Session<'a, A, T>
Sourcepub fn new(author: A, chronofold: &'a mut Chronofold<A, T>) -> Self
pub fn new(author: A, chronofold: &'a mut Chronofold<A, T>) -> Self
Creates an editing session for a single author.
Sourcepub fn push_back(&mut self, value: T) -> LogIndex
pub fn push_back(&mut self, value: T) -> LogIndex
Appends an element to the back of the chronofold and returns the new element’s log index.
Sourcepub fn push_front(&mut self, value: T) -> LogIndex
pub fn push_front(&mut self, value: T) -> LogIndex
Prepends an element to the chronofold and returns the new element’s log index.
Sourcepub fn insert_after(&mut self, index: LogIndex, value: T) -> LogIndex
pub fn insert_after(&mut self, index: LogIndex, value: T) -> LogIndex
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.
Sourcepub fn remove(&mut self, index: LogIndex)
pub fn remove(&mut self, index: LogIndex)
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.
Sourcepub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) -> Option<LogIndex>
pub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) -> Option<LogIndex>
Extends the chronofold with the contents of iter, returns the log
index of the last inserted element, if any.
Sourcepub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Option<LogIndex>
pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Option<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 create_root(&mut self) -> LogIndex
Sourcepub fn iter_ops<V>(&'a self) -> impl Iterator<Item = Op<A, V>> + 'awhere
V: FromLocalValue<'a, A, T> + 'a,
pub fn iter_ops<V>(&'a self) -> impl Iterator<Item = Op<A, V>> + 'awhere
V: FromLocalValue<'a, A, T> + 'a,
Returns an iterator over ops in log order, that where created in this session.