[][src]Struct operational_transform::OperationSeq

pub struct OperationSeq { /* fields omitted */ }

A sequence of Operations on text.

Implementations

impl OperationSeq[src]

pub fn with_capacity(capacity: usize) -> Self[src]

Creates a store for operatations which does not need to allocate until capacity operations have been stored inside.

pub fn compose(&self, other: &Self) -> Result<Self, OTError>[src]

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.

pub fn delete(&mut self, n: u64)[src]

Deletes n characters at the current cursor position.

pub fn insert(&mut self, s: &str)[src]

Inserts a s at the current cursor position.

pub fn retain(&mut self, n: u64)[src]

Moves the cursor n characters forwards.

pub fn transform(&self, other: &Self) -> Result<(Self, Self), OTError>[src]

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.

pub fn apply(&self, s: &str) -> Result<String, OTError>[src]

Applies an operation to a string, returning a new string.

Error

Returns an error if the operation cannot be applied due to length conflicts.

pub fn invert(&self, s: &str) -> Self[src]

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.

pub fn is_noop(&self) -> bool[src]

Checks if this operation has no effect.

pub fn base_len(&self) -> usize[src]

Returns the length of a string these operations can be applied to

pub fn target_len(&self) -> usize[src]

Returns the length of the resulting string after the operations have been applied.

pub fn ops(&self) -> &[Operation][src]

Returns the wrapped sequence of operations.

Trait Implementations

impl Clone for OperationSeq[src]

impl Debug for OperationSeq[src]

impl Default for OperationSeq[src]

impl FromIterator<Operation> for OperationSeq[src]

impl PartialEq<OperationSeq> for OperationSeq[src]

impl StructuralPartialEq for OperationSeq[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.