colla 0.2.0

Operational Transformation library for nested documents with text and rich-text
Documentation
1
2
3
4
5
6
7
8
9
10
use colla::{MapChange, MapEntryChange, TextChange, TextOp, Value};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let base = Value::map([("title", Value::text("Draft"))])?;
    let title = TextChange::from_ops([TextOp::Retain(5), TextOp::Insert(" v2".into())])?;
    let change = MapChange::from_entries([("title", MapEntryChange::Modify(title.into()))])?;
    let after = colla::Change::from(change).apply_to(&base)?;
    println!("{after:?}");
    Ok(())
}