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 { 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}")), } } }