From ead3c6e4a9e1f55ea04a91bed9980332c535d76c Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 22 Mar 2025 16:53:38 -0400 Subject: [PATCH] feat: implement `IntoPyObject` for `HomeAssistant` --- src/home_assistant/home_assistant.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/home_assistant/home_assistant.rs b/src/home_assistant/home_assistant.rs index 64901ed..6104eea 100644 --- a/src/home_assistant/home_assistant.rs +++ b/src/home_assistant/home_assistant.rs @@ -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 { + Ok(self.0.bind(py).to_owned()) + } +} + impl HomeAssistant { /// Return the representation pub fn repr(&self, py: Python<'_>) -> Result {