diff --git a/src/python.rs b/src/python.rs index 463be5fa8..950a514f2 100644 --- a/src/python.rs +++ b/src/python.rs @@ -13,7 +13,7 @@ pub struct PyDataMap { pub(crate) inner: crate::DataMap } -#[pymethods] +#[pyclass] impl PyDataMap { #[new] pub fn new() -> Self { @@ -22,6 +22,7 @@ impl PyDataMap { } } + #[getter] pub fn __str__(&self) -> PyResult { Ok(format!("{:?}", self.inner)) } @@ -35,9 +36,11 @@ impl From for PyDataMap { #[pyclass] #[derive(Clone)] -pub struct PyXorName(crate::XorName); +pub struct PyXorName { + pub(crate) inner: crate::XorName +} -#[pymethods] +#[pyclass] impl PyXorName { #[new] pub fn new(bytes: &[u8]) -> PyResult { @@ -48,17 +51,18 @@ impl PyXorName { } let mut array = [0u8; 32]; array.copy_from_slice(bytes); - Ok(PyXorName(crate::XorName(array))) + Ok(PyXorName { inner: crate::XorName(array) }) } + #[getter] pub fn __str__(&self) -> PyResult { - Ok(hex::encode(self.0 .0)) + Ok(hex::encode(self.inner.0)) } } impl From for PyXorName { fn from(inner: crate::XorName) -> Self { - PyXorName(inner) + PyXorName { inner } } }