mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-22 21:04:53 +01:00
fix(py): explicit getter/setter for user name
This commit is contained in:
parent
8b2a2f2e2e
commit
7cc8e88402
2 changed files with 11 additions and 1 deletions
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,17 @@ impl User {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn get_name(&self) -> pyo3::PyResult<String> {
|
||||
Ok(self.name.clone())
|
||||
}
|
||||
|
||||
#[setter]
|
||||
fn set_name(&mut self, value: String) -> pyo3::PyResult<()> {
|
||||
self.name = value;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn __str__(&self) -> String {
|
||||
format!("{self:?}")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue