diff options
Diffstat (limited to 'lib/sellershut-core/src')
-rw-r--r-- | lib/sellershut-core/src/lib.rs | 8 | ||||
-rw-r--r-- | lib/sellershut-core/src/profile.rs | 4 | ||||
-rw-r--r-- | lib/sellershut-core/src/users.rs | 36 |
3 files changed, 40 insertions, 8 deletions
diff --git a/lib/sellershut-core/src/lib.rs b/lib/sellershut-core/src/lib.rs index 70544cf..afbd20f 100644 --- a/lib/sellershut-core/src/lib.rs +++ b/lib/sellershut-core/src/lib.rs @@ -7,13 +7,13 @@ )] /// Protobuf types -#[cfg(any(feature = "auth", feature = "profile"))] +#[cfg(any(feature = "auth", feature = "users"))] pub mod google; /// Interactions with Auth server #[cfg(feature = "auth")] pub mod auth; -/// Interactions with Profile server -#[cfg(feature = "profile")] -pub mod profile; +/// Interactions with user server +#[cfg(feature = "users")] +pub mod users; diff --git a/lib/sellershut-core/src/profile.rs b/lib/sellershut-core/src/profile.rs deleted file mode 100644 index 06484d9..0000000 --- a/lib/sellershut-core/src/profile.rs +++ /dev/null @@ -1,4 +0,0 @@ -tonic::include_proto!("profile"); -/// Profile file descriptor -pub const PROFILE_FILE_DESCRIPTOR_SET: &[u8] = - tonic::include_file_descriptor_set!("profile_descriptor"); 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}")), + } + } +} |