Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Implement `Change::decode`
Alexis Sellier committed 3 years ago
commit 7e8af47f59e5362c424dcd5cb9d075bd6a4a650a
parent 0448441418579ef34259c18026ca1857b17e2a8f
1 file changed +6 -1
modified radicle-crdt/src/thread.rs
@@ -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)