1use std::str::FromStr;
2
3use crate::Error;
4
5#[derive(
7 Clone, Copy, Debug, Default, PartialEq, Eq, Hash, strum::Display, strum::IntoStaticStr,
8)]
9#[strum(serialize_all = "lowercase")]
10pub enum Scope {
11 #[default]
13 Project,
14 User,
16}
17
18impl Scope {
19 #[must_use]
21 pub fn as_str(self) -> &'static str {
22 self.into()
23 }
24}
25
26impl FromStr for Scope {
30 type Err = Error;
31
32 fn from_str(s: &str) -> Result<Self, Self::Err> {
33 match s {
34 "project" => Ok(Self::Project),
35 "user" => Ok(Self::User),
36 _ => Err(Error::UnknownScope { value: s.to_owned() }),
37 }
38 }
39}