Skip to content

Commit

Permalink
update to latest rust crate and expose SyncState encode decode
Browse files Browse the repository at this point in the history
Signed-off-by: sevenrats <[email protected]>
  • Loading branch information
sevenrats committed Oct 12, 2024
1 parent 40e9d6c commit ab271cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.19.0"
automerge = "0.5.7"
automerge = "0.5.11"
hex = "^0.4.3"
thiserror = "^1.0.16"
10 changes: 10 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,16 @@ impl PySyncState {
pub fn new() -> PySyncState {
PySyncState(am::sync::State::new())
}
pub fn encode<'py>(&self, py: Python<'py>) -> &'py PyBytes {
PyBytes::new(py, &self.0.clone().encode())
}

#[staticmethod]
pub fn decode(bytes: &[u8]) -> PyResult<PySyncState> {
Ok(PySyncState(
am::sync::State::decode(bytes).map_err(|e| PyException::new_err(e.to_string()))?,
))
}
}

#[pyclass(name = "Message")]
Expand Down

0 comments on commit ab271cf

Please sign in to comment.