Skip to content

Commit

Permalink
update PyStreamable to provide IntoPyObject()
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Jan 28, 2025
1 parent 900146d commit 4ea391a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions crates/chia_py_streamable_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ pub fn py_streamable_macro(input: proc_macro::TokenStream) -> proc_macro::TokenS
}
}

impl pyo3::conversion::ToPyObject for #ident {
fn to_object(&self, py: pyo3::Python<'_>) -> pyo3::PyObject {
pyo3::conversion::ToPyObject::to_object(&(*self as u8), py)
}
}

impl pyo3::conversion::IntoPy<pyo3::PyObject> for #ident {
fn into_py(self, py: pyo3::Python<'_>) -> pyo3::PyObject {
pyo3::conversion::ToPyObject::to_object(&(self as u8), py)
impl<'py> pyo3::conversion::IntoPyObject<'py> for #ident {
type Target = pyo3::PyAny;
type Output = pyo3::Bound<'py, Self::Target>;
type Error = std::convert::Infallible;

fn into_pyobject(self, py: pyo3::Python<'py>) -> Result<Self::Output, Self::Error> {
Ok(pyo3::IntoPyObject::into_pyobject(self as u8, py)?
.clone()
.into_any())
}
}
}
Expand Down

0 comments on commit 4ea391a

Please sign in to comment.