ossa_crdt/lib.rs
1// #![feature(non_lifetime_binders)]
2
3pub mod map;
4pub mod register;
5pub mod set;
6pub mod text;
7pub mod time;
8
9use crate::time::CausalState;
10
11// // JP: What should this be called? LogicalOp? MetaOp?
12// pub struct AnnotatedOp<M:OpMetadata, Op> {
13// metadata: M,
14// operation: Op,
15// }
16//
17// pub trait OpMetadata {
18// type Time;
19//
20// /// Logical time, serving as a unique identifier for this operation.
21// fn time(&self) -> Self::Time;
22// }
23
24pub trait CRDT {
25 type Op; // <Time>; // Required due to lack of higher kinded types.
26 type Time; // TODO: Delete this??
27
28 // TODO: enabled...
29
30 // Mut or return Self?
31 // fn apply<'a>(&'a mut self, op: &'a AnnotatedOp<M,Self::Op>); // -> &'a Self;
32
33 // Preconditions:
34 // - All `logical_time`s of applied operations must be unique in all subsequent calls to `apply`.
35 fn apply<CS: CausalState<Time = Self::Time>>(self, causal_state: &CS, op: Self::Op) -> Self;
36
37 // lawCommutativity :: concurrent t1 t2 => x.apply(t1, op1).apply(t2, op2) == x.apply(t2, op2).apply(t1, op1)
38}