accumulo_access/
authorizations.rs

1use std::collections::HashSet;
2
3#[derive(Debug, PartialEq, Clone)]
4pub struct Authorizations {
5    auths: HashSet<String>,
6}
7
8impl Authorizations {
9    /// Creates a new `Authorizations` instance.
10    /// 
11    /// # Arguments 
12    /// 
13    /// * `authorizations`: A vector of authorizations.
14    /// 
15    /// returns: Authorizations 
16    /// 
17    /// # Examples 
18    /// 
19    /// ```
20    /// use std::collections::HashSet;
21    /// use accumulo_access::Authorizations;
22    ///
23    /// let authorizations = Authorizations::of(&["label1".to_string(), "label5".to_string()]);
24    ///
25    /// let expected = HashSet::from_iter(vec!["label1".to_string(), "label5".to_string()]);
26    /// assert_eq!(authorizations.to_set(), expected);
27    /// ```
28    pub fn of(authorizations: &[String]) -> Self {
29        Authorizations {
30            auths: authorizations.iter().cloned().collect()
31        }
32    }
33    
34    pub fn contains(&self, auth: &str) -> bool {
35        self.auths.contains(auth)
36    }
37    
38    pub fn to_set(&self) -> HashSet<String> {
39        self.auths.clone()
40    }
41}