1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::Scope;
#[derive(Debug, Default)]
pub struct Builder {
pub(crate) scopes: Option<Vec<Scope>>,
pub(crate) name: String,
pub(crate) note: String,
}
impl Builder {
pub fn new(name: String) -> Self {
let note = format!("A token created for {}.", &name);
Self {
name,
note,
..Default::default()
}
}
pub fn note(mut self, note: String) -> Self {
self.note = note;
self
}
pub fn scope(mut self, scope: Scope) -> Self {
if let None = self.scopes {
self.scopes = Some(vec![]);
}
if let Some(ref mut scopes) = &mut self.scopes {
scopes.push(scope);
}
self
}
pub fn build(self) -> crate::Authenticator {
crate::Authenticator { config: self }
}
}