Implement Change::decode

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier
2022-11-26 17:13:22 +01:00
parent 0448441418
commit 7e8af47f59
+6 -1
View File
@@ -53,6 +53,11 @@ impl Change {
buf
}
/// Deserialize a change from a byte string.
pub fn decode(bytes: &[u8]) -> Result<Self, serde_json::Error> {
serde_json::from_slice(bytes)
}
}
/// Change envelope. Carries signed changes.
@@ -472,7 +477,7 @@ mod tests {
let actual: Thread = retrieved
.history()
.traverse(Thread::default(), |mut acc, entry| {
let change: Change = serde_json::from_slice(entry.contents()).unwrap();
let change = Change::decode(entry.contents()).unwrap();
acc.apply([change]);
ControlFlow::Continue(acc)