Crate kyte

source ·
Expand description

Extensible mechanics for operational transformation in Rust that are generic with respect to their value (not constrained to text), wire-compatible with Quill and fully fuzzed.

Operational Transformation (OT) enables real-time collaborative editing by enabling two (or more) users to make changes at the same time. An OT-capable central server transforms and broadcasts these changes so everyone is looking at the same synchronized state, even in the presence of severe latency.

This library can be integrated to build both a client-side and/or server-side implementation of operational transformation within your application.

Usage

use kyte::{Compose, Delta, Transform};

let before = Delta::new().insert("Hello World".to_owned(), ());

let alice = Delta::new().retain(5, ()).insert(",".to_owned(), ());
let bob = Delta::new().retain(11, ()).insert("!".to_owned(), ());

assert_eq!(
    before
        .compose(alice)
        .compose(alice.transform(bob, true)),
    before
        .compose(bob)
        .compose(bob.transform(alice, false)),
)

Acknowledgements

This library largely implements Quill’s delta spec and uses some of their test cases for unit testing. Simply put, this library wouldn’t exist without their amazing work on Quill.

Modules

  • Types that represent the insert, retain and delete operations within Kyte.

Structs

  • Series of insert, retain and delete operations.
  • Iterator over Ops with a utility function to zip two iters together and apply a map function that supports partial consumption of either op, as used by Compose and Transform.

Enums

  • Individual insert, retain or delete operation.

Traits

  • Implemented by types that can apply a series of operations in sequence.
  • Implemented by types that have a length (including any type that implements Seq) and all of the Ops.
  • Implemented by any sequence used as the value of a Delta or Op.
  • Implemented by types that can split their value in two at any given index.
  • Implemented by types that can transform another operation to make them behave commutatively (i.e. order-independent).