Struct operational_transform::OperationSeq
source · [−]pub struct OperationSeq { /* private fields */ }
Expand description
A sequence of Operation
s on text.
Implementations
sourceimpl OperationSeq
impl OperationSeq
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a store for operatations which does not need to allocate until
capacity
operations have been stored inside.
sourcepub fn compose(&self, other: &Self) -> Result<Self, OTError>
pub fn compose(&self, other: &Self) -> Result<Self, OTError>
Merges the operation with other
into one operation while preserving
the changes of both. Or, in other words, for each input string S and a
pair of consecutive operations A and B.
apply(apply(S, A), B) = apply(S, compose(A, B))
must hold.
Error
Returns an OTError
if the operations are not composable due to length
conflicts.
sourcepub fn transform(&self, other: &Self) -> Result<(Self, Self), OTError>
pub fn transform(&self, other: &Self) -> Result<(Self, Self), OTError>
Transforms two operations A and B that happened concurrently and produces
two operations A’ and B’ (in an array) such that
apply(apply(S, A), B') = apply(apply(S, B), A')
.
This function is the heart of OT.
Error
Returns an OTError
if the operations cannot be transformed due to
length conflicts.
sourcepub fn apply(&self, s: &str) -> Result<String, OTError>
pub fn apply(&self, s: &str) -> Result<String, OTError>
Applies an operation to a string, returning a new string.
Error
Returns an error if the operation cannot be applied due to length conflicts.
sourcepub fn invert(&self, s: &str) -> Self
pub fn invert(&self, s: &str) -> Self
Computes the inverse of an operation. The inverse of an operation is the operation that reverts the effects of the operation, e.g. when you have an operation ‘insert(“hello “); skip(6);’ then the inverse is ‘delete(“hello “); skip(6);’. The inverse should be used for implementing undo.
sourcepub fn base_len(&self) -> usize
pub fn base_len(&self) -> usize
Returns the length of a string these operations can be applied to
sourcepub fn target_len(&self) -> usize
pub fn target_len(&self) -> usize
Returns the length of the resulting string after the operations have been applied.
Trait Implementations
sourceimpl Clone for OperationSeq
impl Clone for OperationSeq
sourcefn clone(&self) -> OperationSeq
fn clone(&self) -> OperationSeq
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for OperationSeq
impl Debug for OperationSeq
sourceimpl Default for OperationSeq
impl Default for OperationSeq
sourcefn default() -> OperationSeq
fn default() -> OperationSeq
Returns the “default value” for a type. Read more
sourceimpl FromIterator<Operation> for OperationSeq
impl FromIterator<Operation> for OperationSeq
sourcefn from_iter<T: IntoIterator<Item = Operation>>(ops: T) -> Self
fn from_iter<T: IntoIterator<Item = Operation>>(ops: T) -> Self
Creates a value from an iterator. Read more
sourceimpl PartialEq<OperationSeq> for OperationSeq
impl PartialEq<OperationSeq> for OperationSeq
sourcefn eq(&self, other: &OperationSeq) -> bool
fn eq(&self, other: &OperationSeq) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &OperationSeq) -> bool
fn ne(&self, other: &OperationSeq) -> bool
This method tests for !=
.
impl StructuralPartialEq for OperationSeq
Auto Trait Implementations
impl RefUnwindSafe for OperationSeq
impl Send for OperationSeq
impl Sync for OperationSeq
impl Unpin for OperationSeq
impl UnwindSafe for OperationSeq
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more