From 7cc8e88402c790587163c2e2616b0af61265b254 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 16 Oct 2024 03:47:07 +0200 Subject: [PATCH] fix(py): explicit getter/setter for user name --- src/api/user.rs | 1 - src/ffi/python/mod.rs | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/api/user.rs b/src/api/user.rs index c6a6a05..28297fd 100644 --- a/src/api/user.rs +++ b/src/api/user.rs @@ -12,7 +12,6 @@ pub struct User { /// User unique identifier, should never change. pub id: Uuid, /// User name, can change but should be unique. - #[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3(get, set))] pub name: String, } diff --git a/src/ffi/python/mod.rs b/src/ffi/python/mod.rs index e620b39..aaab6a9 100644 --- a/src/ffi/python/mod.rs +++ b/src/ffi/python/mod.rs @@ -170,6 +170,17 @@ impl User { Ok(()) } + #[getter] + fn get_name(&self) -> pyo3::PyResult { + Ok(self.name.clone()) + } + + #[setter] + fn set_name(&mut self, value: String) -> pyo3::PyResult<()> { + self.name = value; + Ok(()) + } + fn __str__(&self) -> String { format!("{self:?}") }