Skip to main content

RoleSet

Struct RoleSet 

Source
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

Source

pub fn new(catalog: &Catalog, roles: Vec<Role>) -> Result<Self>

A set from roles (ids unique, exactly one builtin owner).

Source

pub fn roles(&self) -> Vec<&Role>

The roles, highest rank first.

Source

pub fn get(&self, id: &str) -> Option<&Role>

A role by id.

Source

pub fn by_name(&self, name: &str) -> Option<&Role>

A role by name (case-insensitive).

Source

pub fn owner(&self) -> &Role

The owner role.

Source

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.

Source

pub fn guest(&self) -> Option<&Role>

The guest role, if guests may act.

Source

pub fn can(&self, catalog: &Catalog, actor: &Actor, perm: &str) -> bool

What actor may do (guests only through crate::enforce, which checks Open).

Source

pub fn check_grant(&self, a: &Actor, role: &Role) -> Result<()>

May a give role to someone?

Source

pub fn check_over(&self, a: &Actor, their_role: Option<&str>) -> Result<()>

May a act on a member holding their_role (kick, change role)?

Source

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).

Source

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.

Source

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.

Source

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).

Source

pub fn check_set_role( &self, catalog: &Catalog, a: &Actor, their_role: Option<&str>, new_role: &str, ) -> Result<()>

Checks a change of a member’s role (needs members.role, rank over them, and the right to grant the new role).

Source

pub fn check_kick( &self, catalog: &Catalog, a: &Actor, their_role: Option<&str>, ) -> Result<()>

Checks removing a member (needs members.kick and rank over them).

Trait Implementations§

Source§

impl Clone for RoleSet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RoleSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RoleSet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for RoleSet

Source§

impl PartialEq for RoleSet

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RoleSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RoleSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.