Skip to content

Commit

Permalink
fix(py): explicit getter/setter for user name
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaarf committed Oct 16, 2024
1 parent 8b2a2f2 commit 7cc8e88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/api/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
11 changes: 11 additions & 0 deletions src/ffi/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}")
}
Expand Down

0 comments on commit 7cc8e88

Please sign in to comment.