Trait near_contract_tools::rbac::Rbac
source · pub trait Rbac {
type Role: BorshSerialize + IntoStorageKey;
fn root() -> Slot<()> { ... }
fn slot_members_of(role: &Self::Role) -> Slot<UnorderedSet<AccountId>> { ... }
fn with_members_of_mut<T>(
role: &Self::Role,
f: impl FnOnce(&mut UnorderedSet<AccountId>) -> T
) -> T { ... }
fn with_members_of<T>(
role: &Self::Role,
f: impl Fn(&UnorderedSet<AccountId>) -> T
) -> T { ... }
fn iter_members_of(role: &Self::Role) -> Iter ⓘ { ... }
fn has_role(account_id: &AccountId, role: &Self::Role) -> bool { ... }
fn add_role(&mut self, account_id: AccountId, role: &Self::Role) { ... }
fn remove_role(&mut self, account_id: &AccountId, role: &Self::Role) { ... }
fn require_role(role: &Self::Role) { ... }
fn prohibit_role(role: &Self::Role) { ... }
}
Expand description
Role-based access control
Required Associated Types§
sourcetype Role: BorshSerialize + IntoStorageKey
type Role: BorshSerialize + IntoStorageKey
Roles type (probably an enum).
Provided Methods§
sourcefn slot_members_of(role: &Self::Role) -> Slot<UnorderedSet<AccountId>>
fn slot_members_of(role: &Self::Role) -> Slot<UnorderedSet<AccountId>>
Storage slot for the backing UnorderedSet
of all accounts assigned
to a role.
sourcefn with_members_of_mut<T>(
role: &Self::Role,
f: impl FnOnce(&mut UnorderedSet<AccountId>) -> T
) -> T
fn with_members_of_mut<T>(
role: &Self::Role,
f: impl FnOnce(&mut UnorderedSet<AccountId>) -> T
) -> T
Deserializes the backing UnorderedSet
structure, executes predicate
f
on it, reserializes the structure, and writes it back into storage,
returning the return value of f
.
sourcefn with_members_of<T>(
role: &Self::Role,
f: impl Fn(&UnorderedSet<AccountId>) -> T
) -> T
fn with_members_of<T>(
role: &Self::Role,
f: impl Fn(&UnorderedSet<AccountId>) -> T
) -> T
Deserializes the backing UnorderedSet
structure and executes predicate
f
on it. Returns the return value of f
.
sourcefn iter_members_of(role: &Self::Role) -> Iter ⓘ
fn iter_members_of(role: &Self::Role) -> Iter ⓘ
Iterates over all accounts that have been assigned a role.
sourcefn has_role(account_id: &AccountId, role: &Self::Role) -> bool
fn has_role(account_id: &AccountId, role: &Self::Role) -> bool
Returns whether a given account has been given a certain role.
sourcefn remove_role(&mut self, account_id: &AccountId, role: &Self::Role)
fn remove_role(&mut self, account_id: &AccountId, role: &Self::Role)
Removes a role from an account.
sourcefn require_role(role: &Self::Role)
fn require_role(role: &Self::Role)
Requires transaction predecessor to have a given role.
sourcefn prohibit_role(role: &Self::Role)
fn prohibit_role(role: &Self::Role)
Requires transaction predecessor to not have a given role.