pub struct Role { /* private fields */ }Expand description
A role: a name, an optional identifier and an optional dimension,
written name:identifier/dimension.
use utopia_database::Role;
let role = Role::parse("team:123/owner").unwrap();
assert_eq!(role.name().as_str(), "team");
assert_eq!(role.identifier(), "123");
assert_eq!(role.dimension(), "owner");
assert_eq!(Role::user("123", "verified").to_string(), "user:123/verified");
assert_eq!(Role::parse("users/a/b").unwrap_err().message(), "Only one dimension can be provided");PHP: Utopia\Database\Role. As in PHP, an identifier or a
dimension of "0" is falsy: [Role::to_string] leaves it out, and
Role::parse rejects a "0" dimension as empty.
Implementations§
Source§impl Role
impl Role
Sourcepub fn new(
name: RoleName,
identifier: impl Into<String>,
dimension: impl Into<String>,
) -> Self
pub fn new( name: RoleName, identifier: impl Into<String>, dimension: impl Into<String>, ) -> Self
new Role($role, $identifier, $dimension).
Sourcepub fn named(
name: &str,
identifier: impl Into<String>,
dimension: impl Into<String>,
) -> Self
pub fn named( name: &str, identifier: impl Into<String>, dimension: impl Into<String>, ) -> Self
A role from its name as text (new Role('team', ...)).
Sourcepub fn identifier(&self) -> &str
pub fn identifier(&self) -> &str
The identifier, empty when none (getIdentifier()).
Sourcepub fn parse(role: &str) -> Result<Self>
pub fn parse(role: &str) -> Result<Self>
Role::parse($role): name, name:identifier, name/dimension or
name:identifier/dimension. Only the first : separates the
identifier; text after a second : is dropped, as PHP does.
Fails (crate::Kind::Exception, PHP’s \Exception) with Only one dimension can be provided or Dimension must not be empty.
Sourcepub fn user(identifier: impl Into<String>, status: impl Into<String>) -> Self
pub fn user(identifier: impl Into<String>, status: impl Into<String>) -> Self
Role::user($identifier, $status).
Trait Implementations§
impl Eq for Role
impl StructuralPartialEq for Role
Auto Trait Implementations§
impl Forget for Role
impl Freeze for Role
impl Move for Role
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnsafeUnpin for Role
impl UnwindSafe for Role
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.