diff --git a/home-assistant/src/object_id.rs b/home-assistant/src/object_id.rs index b19a236..98ecf94 100644 --- a/home-assistant/src/object_id.rs +++ b/home-assistant/src/object_id.rs @@ -1,21 +1,11 @@ use std::convert::Infallible; use pyo3::{prelude::*, types::PyString}; +use python_utils::{FromPyFromStr, ToStrToPy}; use super::slug::Slug; pub use super::slug::SlugParsingError as ObjectIdParsingError; -#[derive(Debug, Clone, derive_more::Display, derive_more::FromStr)] +#[derive(Debug, Clone, derive_more::FromStr, derive_more::Display, FromPyFromStr, ToStrToPy)] pub struct ObjectId(pub Slug); - -impl<'py> IntoPyObject<'py> for ObjectId { - type Target = PyString; - type Output = Bound<'py, Self::Target>; - type Error = Infallible; - - fn into_pyobject(self, py: Python<'py>) -> Result { - let s = self.to_string(); - s.into_pyobject(py) - } -}