feat: implement IntoPyObject for HomeAssistant

This commit is contained in:
2025-03-22 16:53:38 -04:00
parent 04f9aa24cf
commit ead3c6e4a9

View File

@@ -1,3 +1,5 @@
use std::convert::Infallible;
use pyo3::prelude::*;
use crate::python_utils::{detach, validate_type_by_name};
@@ -17,6 +19,16 @@ impl<'source> FromPyObject<'source> for HomeAssistant {
}
}
impl<'py> IntoPyObject<'py> for &HomeAssistant {
type Target = PyAny;
type Output = Bound<'py, Self::Target>;
type Error = Infallible;
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
Ok(self.0.bind(py).to_owned())
}
}
impl HomeAssistant {
/// Return the representation
pub fn repr(&self, py: Python<'_>) -> Result<String, PyErr> {