Skip to content

Commit

Permalink
Add validate
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Dec 11, 2024
1 parent 17cfc0e commit 5358538
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/ommx/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ impl Instance {
#[staticmethod]
pub fn from_bytes(bytes: &Bound<PyBytes>) -> Result<Self> {
let inner = ommx::v1::Instance::decode(bytes.as_bytes())?;
inner.validate()?;
Ok(Self(inner))
}

pub fn to_bytes<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyBytes>> {
Ok(PyBytes::new_bound(py, &self.0.encode_to_vec()))
}

pub fn validate(&self) -> Result<()> {
self.0.validate()
}

pub fn as_pubo_format<'py>(&self, py: Python<'py>) -> Result<Bound<'py, PyDict>> {
let pubo = self.0.as_pubo_format()?;
Ok(serde_pyobject::to_pyobject(py, &pubo)?.extract()?)
Expand Down

0 comments on commit 5358538

Please sign in to comment.