Implement `Change::decode`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
0448441418
commit
7e8af47f59
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue