pub enum AccessLevel {
NotVisible,
ReadOnly,
Edit,
}Expand description
Granular access level for a resource type.
Access levels are ordered from most restrictive to least restrictive:
NotVisible < ReadOnly < Edit
This ordering allows permission checks to verify if a user has “at least” a certain level of access.
Variants§
NotVisible
Resource is hidden - member cannot see it exists.
Use this for sensitive resources that should be completely invisible to certain members (e.g., admin settings for guests).
ReadOnly
Read-only access - can view but not modify.
Members with this level can:
- View resource content
- List resources
- Read metadata
Members cannot:
- Create new resources
- Modify existing resources
- Delete resources
Edit
Full access - can view, create, modify, and delete.
Members with this level have complete control over the resource type, subject to other constraints (e.g., cannot delete resources created by others without additional permissions).
Implementations§
Source§impl AccessLevel
impl AccessLevel
Sourcepub fn allows(self, required: AccessLevel) -> bool
pub fn allows(self, required: AccessLevel) -> bool
Check if this access level allows the required level.
Returns true if self is at least as permissive as required.
§Examples
use communitas_bindings::permissions::AccessLevel;
assert!(AccessLevel::Edit.allows(AccessLevel::ReadOnly));
assert!(AccessLevel::Edit.allows(AccessLevel::Edit));
assert!(!AccessLevel::ReadOnly.allows(AccessLevel::Edit));
assert!(!AccessLevel::NotVisible.allows(AccessLevel::ReadOnly));Sourcepub fn can_view(self) -> bool
pub fn can_view(self) -> bool
Check if this access level can view the resource.
Returns true for ReadOnly and Edit levels.
Trait Implementations§
Source§impl Clone for AccessLevel
impl Clone for AccessLevel
Source§fn clone(&self) -> AccessLevel
fn clone(&self) -> AccessLevel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for AccessLevel
Source§impl Debug for AccessLevel
impl Debug for AccessLevel
Source§impl Default for AccessLevel
impl Default for AccessLevel
Source§impl<'de> Deserialize<'de> for AccessLevel
impl<'de> Deserialize<'de> for AccessLevel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for AccessLevel
impl Display for AccessLevel
impl Eq for AccessLevel
Source§impl FromStr for AccessLevel
impl FromStr for AccessLevel
Source§impl Hash for AccessLevel
impl Hash for AccessLevel
Source§impl Ord for AccessLevel
impl Ord for AccessLevel
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for AccessLevel
impl PartialEq for AccessLevel
Source§impl PartialOrd for AccessLevel
impl PartialOrd for AccessLevel
Source§impl Serialize for AccessLevel
impl Serialize for AccessLevel
impl StructuralPartialEq for AccessLevel
Auto Trait Implementations§
impl Freeze for AccessLevel
impl RefUnwindSafe for AccessLevel
impl Send for AccessLevel
impl Sync for AccessLevel
impl Unpin for AccessLevel
impl UnsafeUnpin for AccessLevel
impl UnwindSafe for AccessLevel
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
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more