pub fn add_role(&mut self, name: &'static str, parents: Vec<&'static str>) -> Result<(), Error> {
        trace!("adding role {} with parents {:?}", name, parents);
        if self.roles.contains_key(name) {
            warn!("adding duplicate role: {}", name);
            return Err(Error::DuplicateRole(String::from(name)));
        } // if
        if parents.len() > 0 {
            let mut reversed = parents.clone();

            for name in parents {
                if !self.roles.contains_key(name) {
                    warn!("missing parent for new role: {}", name);
                    return Err(Error::MissingParent(String::from(name)))
                } // if
            } // for
            reversed.reverse();
            self.roles.insert(name, reversed);
        } else {
            self.roles.insert(name, vec![]);
        } // else
        Ok(())
    }
/// Adds a new role. Returns an error if role is already defined or parent is unknown.
Adds a new role. Returns an error if role is already defined or parent is unknown.
Adds a new role . Returns an error if role is already defined or parent is unknown .
pub fn add_role(&mut self, name: &'static str, parents: Vec<&'static str>) -> Result<(), Error> {
        trace!("adding role {} with parents {:?}", name, parents);
        if self.roles.contains_key(name) {
            warn!("adding duplicate role: {}", name);
            return Err(Error::DuplicateRole(String::from(name)));
        } // if
        if parents.len() > 0 {
            let mut reversed = parents.clone();
            for name in parents {
                if !self.roles.contains_key(name) {
                    warn!("missing parent for new role: {}", name);
                    return Err(Error::MissingParent(String::from(name)))
                } // if
            } // for
            reversed.reverse();
            self.roles.insert(name, reversed);
        } else {
            self.roles.insert(name, vec![]);
        } // else
        Ok(())
    }
pub fn add_role ( & mut self , name : & ' static str , parents : Vec < & ' static str > ) -> Result < ( ) , Error > { trace ! ( " " name parents ) ; if self . roles . contains_key ( name ) { warn ! ( " " name ) ; return Err ( Error :: DuplicateRole ( String :: from ( name ) ) ) ; } // if if parents . len ( ) > 0 { let mut reversed = parents . clone ( ) ; for name in parents { if ! self . roles . contains_key ( name ) { warn ! ( " " name ) ; return Err ( Error :: MissingParent ( String :: from ( name ) ) ) } // if } // for reversed . reverse ( ) ; self . roles . insert ( name , reversed ) ; } else { self . roles . insert ( name , vec ! [ ] ) ; } // else Ok ( ( ) ) }
Adds a new role.
Adds a new role .
&mut self
name
&'static str
parents
Vec<&'static str>
&mut self
name
&'static str
parents
Vec<&'static str>