chore(home-assistant): streamline ObjectId's Python definitions

This commit is contained in:
2026-07-14 20:04:15 -04:00
parent 41cf9d0d09
commit 9863029eb9

View File

@@ -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<Self::Output, Self::Error> {
let s = self.to_string();
s.into_pyobject(py)
}
}