serde-diff
A small helper that can
- Serialize the fields that differ between two structs of the same type
- Apply previously serialized field differences to other structs.
The SerdeDiff trait impl can serialize field paths recursively, greatly reducing the amount of data that needs to be serialized.
TODO: crates.io badge
Status
Works for most basic use-cases. Includes derive macro, some standard library type implementations and deep serde integration. Supports diffing Vec. Supports both text and binary serde formats.
Usage
On a struct:
#[derive(SerdeDiff, Serialize, Deserialize)]
Serialize & apply differences:
bincode
let bincode_data = bincode::serialize(&Diff::serializable(&old, &new)).unwrap();
bincode::config()
.deserialize_seed(Apply::deserializable(&mut target), &bincode_data)
.unwrap();
serde_json
let mut deserializer = serde_json::Deserializer::from_str(&json_data);
Apply::apply(&mut deserializer, &mut target).unwrap();
Contribution
All contributions are assumed to be dual-licensed under MIT/Apache-2.
License
Distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT.