chore(home-assistant): streamline Python conversion for ServiceDomain and ServiceId

This commit is contained in:
2026-07-14 20:24:27 -04:00
parent 34d0266c1f
commit 338a8c571c
2 changed files with 4 additions and 30 deletions

View File

@@ -1,21 +1,8 @@
use std::convert::Infallible;
use pyo3::{prelude::*, types::PyString};
use python_utils::{FromPyFromStr, ToStrToPy};
use super::super::slug::Slug;
pub use super::super::slug::SlugParsingError as ServiceDomainParsingError;
#[derive(Debug, Clone, derive_more::Display, derive_more::FromStr)]
#[derive(Debug, Clone, derive_more::FromStr, derive_more::Display, FromPyFromStr, ToStrToPy)]
pub struct ServiceDomain(pub Slug);
impl<'py> IntoPyObject<'py> for ServiceDomain {
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)
}
}

View File

@@ -1,21 +1,8 @@
use std::convert::Infallible;
use pyo3::{prelude::*, types::PyString};
use python_utils::{FromPyFromStr, ToStrToPy};
use super::super::slug::Slug;
pub use super::super::slug::SlugParsingError as ServiceIdParsingError;
#[derive(Debug, Clone, derive_more::Display, derive_more::FromStr)]
#[derive(Debug, Clone, derive_more::FromStr, derive_more::Display, FromPyFromStr, ToStrToPy)]
pub struct ServiceId(pub Slug);
impl<'py> IntoPyObject<'py> for ServiceId {
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)
}
}