1use serde::{Deserialize, Serialize};
2
3#[non_exhaustive]
4#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub struct Scope {
6 #[serde(skip_serializing_if = "Option::is_none")]
7 pub user: Option<String>,
8 #[serde(skip_serializing_if = "Option::is_none")]
9 pub project: Option<String>,
10}
11
12impl Scope {
13 pub fn personal(user: impl Into<String>) -> Self {
14 Self {
15 user: Some(user.into()),
16 project: None,
17 }
18 }
19
20 pub fn force_personal(user: impl Into<String>) -> Self {
21 Self {
22 user: Some(user.into()),
23 project: Some(String::new()),
24 }
25 }
26
27 pub fn project(user: impl Into<String>, project: impl Into<String>) -> Self {
28 Self {
29 user: Some(user.into()),
30 project: Some(project.into()),
31 }
32 }
33
34 pub fn is_empty(&self) -> bool {
35 self.user.is_none() && self.project.is_none()
36 }
37}