pub trait ReflectIntermediate {
// Provided methods
fn patch_change(&mut self, _change: &Change) { ... }
fn before_patch_change(&mut self) { ... }
fn after_patch_change(&mut self) { ... }
}
Expand description
Trait used to enable patching changes directly into data.
Prefer to implement using ReflectIntermediate
derive macro.
Example
use serde::{Serialize, Deserialize};
use serde_intermediate::{Change, ReflectIntermediate};
#[derive(Debug, PartialEq, Serialize, Deserialize, ReflectIntermediate)]
struct Foo(bool);
let mut a = Foo(false);
let b = Foo(true);
let change = Change::data_difference(&a, &b, &Default::default()).unwrap();
a.patch_change(&change);
assert_eq!(a, b);