Struct spawn_access_control::RoleManager
source · pub struct RoleManager { /* private fields */ }Expand description
§RoleManager: A Library for Managing Ownership and Roles in WASM
RoleManager provides a secure mechanism to manage ownership, roles,
and access control in WebAssembly (WASM) environments.
§Features:
- Ownership transfer
- Role assignment and removal
- Role-based access control (RBAC)
§Usage:
RoleManager is designed to manage contract ownership and roles, ensuring only authorized users can perform certain actions.
§Example
let mut role_manager = RoleManager::new("admin");
role_manager.assign_role("admin", "editor", "user1").unwrap();
assert!(role_manager.has_role("editor", "user1"));Implementations§
source§impl RoleManager
impl RoleManager
sourcepub fn new(owner: &str) -> RoleManager
pub fn new(owner: &str) -> RoleManager
sourcepub fn transfer_ownership(
&mut self,
current_owner: &str,
new_owner: &str,
) -> Result<(), String>
pub fn transfer_ownership( &mut self, current_owner: &str, new_owner: &str, ) -> Result<(), String>
sourcepub fn role_based_access(&self, user: &str, role: &str) -> bool
pub fn role_based_access(&self, user: &str, role: &str) -> bool
Trait Implementations§
source§impl From<RoleManager> for JsValue
impl From<RoleManager> for JsValue
source§fn from(value: RoleManager) -> Self
fn from(value: RoleManager) -> Self
Converts to this type from the input type.
source§impl FromWasmAbi for RoleManager
impl FromWasmAbi for RoleManager
source§impl IntoWasmAbi for RoleManager
impl IntoWasmAbi for RoleManager
source§impl LongRefFromWasmAbi for RoleManager
impl LongRefFromWasmAbi for RoleManager
source§impl OptionFromWasmAbi for RoleManager
impl OptionFromWasmAbi for RoleManager
source§impl OptionIntoWasmAbi for RoleManager
impl OptionIntoWasmAbi for RoleManager
source§impl RefFromWasmAbi for RoleManager
impl RefFromWasmAbi for RoleManager
source§type Anchor = RcRef<RoleManager>
type Anchor = RcRef<RoleManager>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.source§impl RefMutFromWasmAbi for RoleManager
impl RefMutFromWasmAbi for RoleManager
source§impl TryFromJsValue for RoleManager
impl TryFromJsValue for RoleManager
source§impl VectorFromWasmAbi for RoleManager
impl VectorFromWasmAbi for RoleManager
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[RoleManager]>
source§impl VectorIntoJsValue for RoleManager
impl VectorIntoJsValue for RoleManager
fn vector_into_jsvalue(vector: Box<[RoleManager]>) -> JsValue
source§impl VectorIntoWasmAbi for RoleManager
impl VectorIntoWasmAbi for RoleManager
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[RoleManager]>) -> Self::Abi
source§impl WasmDescribeVector for RoleManager
impl WasmDescribeVector for RoleManager
Auto Trait Implementations§
impl Freeze for RoleManager
impl RefUnwindSafe for RoleManager
impl Send for RoleManager
impl Sync for RoleManager
impl Unpin for RoleManager
impl UnwindSafe for RoleManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::Abisource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.