diff options
author | rtkay123 <dev@kanjala.com> | 2025-07-27 18:16:41 +0200 |
---|---|---|
committer | rtkay123 <dev@kanjala.com> | 2025-07-27 18:16:41 +0200 |
commit | 3c4d17cf2840c643b8cd111ef775750cc5ae83b3 (patch) | |
tree | 2b7d25b24d94141a6d9255426d4f973cced5d278 /lib/sellershut-core/src/users.rs | |
parent | e26d87f4fa18999c6bcfbcf32cfa85adab11acdd (diff) | |
download | sellershut-3c4d17cf2840c643b8cd111ef775750cc5ae83b3.tar.bz2 sellershut-3c4d17cf2840c643b8cd111ef775750cc5ae83b3.zip |
refactor: profile -> users
Diffstat (limited to 'lib/sellershut-core/src/users.rs')
-rw-r--r-- | lib/sellershut-core/src/users.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/sellershut-core/src/users.rs b/lib/sellershut-core/src/users.rs new file mode 100644 index 0000000..5721d53 --- /dev/null +++ b/lib/sellershut-core/src/users.rs @@ -0,0 +1,36 @@ +tonic::include_proto!("users"); +/// Users file descriptor +pub const USERS_FILE_DESCRIPTOR_SET: &[u8] = + tonic::include_file_descriptor_set!("users_descriptor"); + +impl std::fmt::Display for UserType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + UserType::Person => "person", + UserType::Application => "application", + UserType::Group => "group", + UserType::Organization => "organization", + UserType::Service => "service", + } + .to_uppercase() + ) + } +} + +impl std::str::FromStr for UserType { + type Err = String; + + fn from_str(value: &str) -> Result<Self, Self::Err> { + match value.to_lowercase().as_str() { + "person" => Ok(Self::Person), + "application" => Ok(Self::Application), + "group" => Ok(Self::Group), + "organization" => Ok(Self::Organization), + "service" => Ok(Self::Service), + _ => Err(format!("invalid user type: {value}")), + } + } +} |