mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-21 23:04:49 +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.
|
/// User unique identifier, should never change.
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
/// User name, can change but should be unique.
|
/// User name, can change but should be unique.
|
||||||
#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3(get, set))]
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,17 @@ impl User {
|
||||||
Ok(())
|
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 {
|
fn __str__(&self) -> String {
|
||||||
format!("{self:?}")
|
format!("{self:?}")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue