mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-16 00:00:37 +08:00
Implement Change::decode
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user