[−][src]Struct chronofold::Session
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
impl<'a, A: Author, T: Debug> Session<'a, A, T>
[src]
pub fn new(author: A, chronofold: &'a mut Chronofold<A, T>) -> Self
[src]
Creates an editing session for a single author.
pub fn clear(&mut self)
[src]
Clears the chronofold, removing all elements.
pub fn push_back(&mut self, value: T) -> LogIndex
[src]
Appends an element to the back of the chronofold and returns the new element's log index.
pub fn push_front(&mut self, value: T) -> LogIndex
[src]
Prepends an element to the chronofold and returns the new element's log index.
pub fn insert_after(&mut self, index: Option<LogIndex>, value: T) -> LogIndex
[src]
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.
pub fn remove(&mut self, index: LogIndex)
[src]
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
.
pub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) -> Option<LogIndex>
[src]
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>,
[src]
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.
impl<'a, A: Author, T: Clone> Session<'a, A, T>
[src]
pub fn iter_ops(&'a self) -> impl Iterator<Item = Op<A, T>> + 'a
[src]
Returns an iterator over ops in log order, that where created in this session.
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, A: Debug + Author, T: Debug> Debug for Session<'a, A, T>
[src]
Auto Trait Implementations
impl<'a, A, T> RefUnwindSafe for Session<'a, A, T> where
A: RefUnwindSafe,
T: RefUnwindSafe,
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, A, T> Send for Session<'a, A, T> where
A: Send,
T: Send,
A: Send,
T: Send,
impl<'a, A, T> Sync for Session<'a, A, T> where
A: Sync,
T: Sync,
A: Sync,
T: Sync,
impl<'a, A, T> Unpin for Session<'a, A, T> where
A: Unpin,
A: Unpin,
impl<'a, A, T> !UnwindSafe for Session<'a, A, T>
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, 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>,