pub struct RoleSet {
pub apply_role: Option<String>,
pub invite_role: Option<String>,
pub guest_role: Option<String>,
/* private fields */
}Expand description
A resource’s roles and its defaults for new members and guests.
Fields§
§apply_role: Option<String>What approved join requests get.
invite_role: Option<String>What invitees get.
guest_role: Option<String>What guests act under on Open resources.
Implementations§
Source§impl RoleSet
impl RoleSet
Sourcepub fn new(catalog: &Catalog, roles: Vec<Role>) -> Result<Self>
pub fn new(catalog: &Catalog, roles: Vec<Role>) -> Result<Self>
A set from roles (ids unique, exactly one builtin owner).
Sourcepub fn actor(&self, user_id: &str, role_id: &str) -> Option<Actor>
pub fn actor(&self, user_id: &str, role_id: &str) -> Option<Actor>
The actor for a member holding role role_id (from their membership). None if
the role is gone.
Sourcepub fn can(&self, catalog: &Catalog, actor: &Actor, perm: &str) -> bool
pub fn can(&self, catalog: &Catalog, actor: &Actor, perm: &str) -> bool
What actor may do (guests only through crate::enforce, which checks Open).
Sourcepub fn check_over(&self, a: &Actor, their_role: Option<&str>) -> Result<()>
pub fn check_over(&self, a: &Actor, their_role: Option<&str>) -> Result<()>
May a act on a member holding their_role (kick, change role)?
Sourcepub fn create(
&mut self,
catalog: &Catalog,
a: &Actor,
name: &str,
rank: i64,
perms: &[&str],
) -> Result<&Role>
pub fn create( &mut self, catalog: &Catalog, a: &Actor, name: &str, rank: i64, perms: &[&str], ) -> Result<&Role>
Creates a role ranked below a’s own (needs roles.manage).
Sourcepub fn edit(
&mut self,
catalog: &Catalog,
a: &Actor,
id: &str,
name: Option<&str>,
rank: Option<i64>,
perms: Option<&[&str]>,
) -> Result<&Role>
pub fn edit( &mut self, catalog: &Catalog, a: &Actor, id: &str, name: Option<&str>, rank: Option<i64>, perms: Option<&[&str]>, ) -> Result<&Role>
Edits a role ranked below a’s own. The owner role can’t be changed.
Sourcepub fn remove(&mut self, catalog: &Catalog, a: &Actor, id: &str) -> Result<Role>
pub fn remove(&mut self, catalog: &Catalog, a: &Actor, id: &str) -> Result<Role>
Removes a role ranked below a’s own; returns the role its members move to (the
lowest remaining). The owner role and the current defaults can’t be removed.
Sourcepub fn set_defaults(
&mut self,
catalog: &Catalog,
a: &Actor,
apply: Option<&str>,
invite: Option<&str>,
guest: Option<Option<&str>>,
) -> Result<()>
pub fn set_defaults( &mut self, catalog: &Catalog, a: &Actor, apply: Option<&str>, invite: Option<&str>, guest: Option<Option<&str>>, ) -> Result<()>
Sets the defaults (needs members.defaults; each role must be one a may grant).