# Deltastruct #
This library provides tools for diffing structs and serializing them.
## Deltas
Deltas are effectively a slice of tuples each with a corrisponding field id,
a modification function id, and curried (or closed over) inputs to that function.
When a delta is applied to data, each of these fields is iterated over and modified
using the given function.
```rust
struct Foo {
a : i32,
b : f64,
c : Vec<usize>
}
impl i32 {
#[deltafunc]
fn set(&self, newval : Self) -> Self {
newval
}
}
// -->
struct FooDelta {
deltas : Vec<FooDeltaField>
}
enum FooDeltaFieldName {
#(Foo.fields(field.ty))
}
impl FooDeltaFieldName {
fn to_field_id() -> usize;
}
struct FooDeltaField {
field : FooDeltaFieldName,
func : &fn(FooDeltaFieldName) -> FooDeltaFieldName
}
enum i32DeltaFunc {
Set(Self)
}
fn test {
f = Foo{ 1, 2.5, vec![]};
fd = FooDelta {
deltas : vec![
FooDeltaField {
field: FooDeltaFieldName::a(),
func: i32DeltaFunc::Set(5)
}
]
};
f.apply_delta(fd); // -> Foo { 5, 2.5, vec![] }
}
```