feat: implement IntoPyObject for EntityId

This commit is contained in:
2025-03-22 16:53:26 -04:00
parent 70dda580ee
commit 04f9aa24cf

View File

@@ -1,6 +1,6 @@
use std::{fmt::Display, str::FromStr}; use std::{convert::Infallible, fmt::Display, str::FromStr};
use pyo3::{exceptions::PyValueError, prelude::*}; use pyo3::{exceptions::PyValueError, prelude::*, types::PyString};
use snafu::{ResultExt, Snafu}; use snafu::{ResultExt, Snafu};
use super::{ use super::{
@@ -58,3 +58,14 @@ impl<'py> FromPyObject<'py> for EntityId {
Ok(entity_id) Ok(entity_id)
} }
} }
impl<'py> IntoPyObject<'py> for &EntityId {
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)
}
}