Skip to content

Commit ab271cf

Browse files
committed
update to latest rust crate and expose SyncState encode decode
Signed-off-by: sevenrats <[email protected]>
1 parent 40e9d6c commit ab271cf

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

rust/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ crate-type = ["cdylib"]
1010

1111
[dependencies]
1212
pyo3 = "0.19.0"
13-
automerge = "0.5.7"
13+
automerge = "0.5.11"
1414
hex = "^0.4.3"
1515
thiserror = "^1.0.16"

rust/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,16 @@ impl PySyncState {
742742
pub fn new() -> PySyncState {
743743
PySyncState(am::sync::State::new())
744744
}
745+
pub fn encode<'py>(&self, py: Python<'py>) -> &'py PyBytes {
746+
PyBytes::new(py, &self.0.clone().encode())
747+
}
748+
749+
#[staticmethod]
750+
pub fn decode(bytes: &[u8]) -> PyResult<PySyncState> {
751+
Ok(PySyncState(
752+
am::sync::State::decode(bytes).map_err(|e| PyException::new_err(e.to_string()))?,
753+
))
754+
}
745755
}
746756

747757
#[pyclass(name = "Message")]

0 commit comments

Comments
 (0)