1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
mod aggregated; pub use aggregated::*;
mod cell; pub use cell::*;
mod context; pub use context::*;
mod dict; pub use dict::*;
mod sequence; pub use sequence::*;
mod time; pub use time::*;
#[cfg(test)] mod test;
pub trait Mergable: Sized {
type Diff;
fn merge(&mut self, other: Self) {
self.apply(Mergable::diff(&other, self))
.expect("Implementation error")
}
fn diff(&self, that: &Self) -> Self::Diff;
fn apply(&mut self, diff: Self::Diff) -> Result<(), ApplyError>;
}
#[derive(Debug,thiserror::Error)]
#[non_exhaustive]
pub enum ApplyError {
#[error("Apply target missing critical information: {0:?}")]
Missing(String),
}
#[derive(Clone,Debug)]
pub struct Opaque<T>(T);