a collection of well-tested, serializable CRDTs for Rust
Clone or download
davidrusu Merge pull request #30 from lucab/ups/gcounter-overflow
counters: use big-integers to avoid overflows
Latest commit ca63d91 Nov 11, 2018

README.md

rust-crdt

Build Status crates.io

Thoroughly tested serializable practical CRDT's ported from riak_dt.

documentation

  • Vector Clock
  • ORSWOT
  • LWW Register
  • G-Counter
  • Top-K Set
  • Map
  • G-Set
  • OR-Set
  • PN-Counter
  • EM-Counter

examples

OR-Set Without Tombstones (ORSWOT)

let (mut a, mut b) = (Orswot::new(), Orswot::new());
a.add("value bar".to_string(), "witnessing node A".to_string());
assert_eq!(a.value(), vec!["value bar".to_string()]);
b.add("value baz".to_string(), "witnessing node B".to_string());
assert_eq!(b.value(), vec!["value baz".to_string()]);
let mut c = a.clone();
assert_eq!(c.value(), vec!["value bar".to_string()]);
c.merge(b);
assert_eq!(c.value(), vec!["value bar".to_string(), "value baz".to_string()]);
unsafe { a.remove("value bar".to_string()); }
let mut d = a.clone();
d.merge(c);
assert_eq!(d.value(), vec!["value baz".to_string()]);

If you want to learn about how CRDTs work, I suggest starting with the readme from aphyr's meangirls repo. Afterwards, either check out the riak dt source code or A comprehensive study of CRDTs depending on if you like to read papers or jump straight to source code examples.

references