pub enum AccessLevel {
None,
Read,
Comment,
Write,
Admin,
}Expand description
Access level enum for files
The variant order IS the ordering (None < Read < Comment < Write < Admin), so Ord lets
callers cap one level by another — e.g. a share manager may not grant more than they hold.
Variants§
Implementations§
Source§impl AccessLevel
impl AccessLevel
pub fn as_str(&self) -> &'static str
Sourcepub fn from_str_name(s: &str) -> Option<Self>
pub fn from_str_name(s: &str) -> Option<Self>
Parse the wire/attribute name produced by AccessLevel::as_str, for call sites that
receive a level as an untyped string (the ABAC object attribute bag). Unknown names yield
None so a caller denies rather than guessing.
Sourcepub fn from_perm_char(c: char) -> Self
pub fn from_perm_char(c: char) -> Self
Convert a permission char (‘R’, ‘C’, ‘W’, ‘A’) to an access level.
The single converter for the permission CHAR(1) vocabulary used by share_entries,
file_user_data.access_level and ref rows. 'A' is a distinct level, not a synonym for
write: it additionally confers share management. Unknown chars fall back to Read —
fail-safe for a corrupt row, which the adapter logs.
Sourcepub fn to_perm_char(self) -> Option<char>
pub fn to_perm_char(self) -> Option<char>
Map an access level back to its single-char wire form.
Injective inverse of AccessLevel::from_perm_char. None has no char — the caller
should clear the stored value rather than write a stale 'R'.
Sourcepub fn to_scope_char(self) -> Option<char>
pub fn to_scope_char(self) -> Option<char>
Map an access level to the char used inside a token scope (file:{id}:{R|C|W}).
Deliberately lossy at the top: Admin caps to 'W'. share_access refuses every scoped
caller, so admin inside a scope would be unusable, and emitting it risks a parser elsewhere
reading it as authority.
None has no char, mirroring AccessLevel::to_perm_char: a scope is a grant, so “no
access” must not silently become a read scope. Callers already hold >= Read, making the
None arm a compile-time reminder rather than a live path.
Sourcepub fn can_comment(self) -> bool
pub fn can_comment(self) -> bool
May comment on the resource.
Sourcepub fn can_write(self) -> bool
pub fn can_write(self) -> bool
May modify the resource. True for Admin too — use ordering, never == Write.
May manage the resource’s share set (grant, revoke, mint share links).
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 more