#[repr(u8)]pub enum PermissionLevel {
None = 0,
Read = 1,
Write = 2,
Execute = 3,
Admin = 4,
}Expand description
Permission level that determines what operations are allowed.
Levels are hierarchical: a higher level automatically grants all lower levels.
For example, Write permission implies Read permission.
Variants§
None = 0
No permission granted
Read = 1
Read-only access: view contents, list directories, search
Write = 2
Read + create/modify: includes all Read operations plus file creation and modification
Execute = 3
Read + Write + execute: includes running commands and scripts
Admin = 4
Full access: includes all operations plus dangerous ones (delete, system commands)
Implementations§
Source§impl PermissionLevel
impl PermissionLevel
Sourcepub fn from_u8(value: u8) -> Option<PermissionLevel>
pub fn from_u8(value: u8) -> Option<PermissionLevel>
Creates a permission level from a numeric value.
Returns None if the value is out of range (> 4).
Sourcepub fn satisfies(self, required: PermissionLevel) -> bool
pub fn satisfies(self, required: PermissionLevel) -> bool
Checks if this permission level satisfies a required level.
A level satisfies another if it is greater than or equal to the required level. This implements the permission hierarchy where higher levels imply lower levels.
§Examples
use agent_core_runtime::permissions::PermissionLevel;
assert!(PermissionLevel::Write.satisfies(PermissionLevel::Read));
assert!(PermissionLevel::Admin.satisfies(PermissionLevel::Execute));
assert!(!PermissionLevel::Read.satisfies(PermissionLevel::Write));Sourcepub fn implied_levels(self) -> Vec<PermissionLevel>
pub fn implied_levels(self) -> Vec<PermissionLevel>
Returns all permission levels that this level implies.
For example, Write implies both Write and Read.
Sourcepub fn all() -> &'static [PermissionLevel]
pub fn all() -> &'static [PermissionLevel]
Returns all permission levels as a slice.
Trait Implementations§
Source§impl Clone for PermissionLevel
impl Clone for PermissionLevel
Source§fn clone(&self) -> PermissionLevel
fn clone(&self) -> PermissionLevel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PermissionLevel
impl Debug for PermissionLevel
Source§impl Default for PermissionLevel
impl Default for PermissionLevel
Source§fn default() -> PermissionLevel
fn default() -> PermissionLevel
Source§impl<'de> Deserialize<'de> for PermissionLevel
impl<'de> Deserialize<'de> for PermissionLevel
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PermissionLevel, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PermissionLevel, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for PermissionLevel
impl Display for PermissionLevel
Source§impl Hash for PermissionLevel
impl Hash for PermissionLevel
Source§impl Ord for PermissionLevel
impl Ord for PermissionLevel
Source§fn cmp(&self, other: &PermissionLevel) -> Ordering
fn cmp(&self, other: &PermissionLevel) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PermissionLevel
impl PartialEq for PermissionLevel
Source§impl PartialOrd for PermissionLevel
impl PartialOrd for PermissionLevel
Source§impl Serialize for PermissionLevel
impl Serialize for PermissionLevel
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for PermissionLevel
impl Eq for PermissionLevel
impl StructuralPartialEq for PermissionLevel
Auto Trait Implementations§
impl Freeze for PermissionLevel
impl RefUnwindSafe for PermissionLevel
impl Send for PermissionLevel
impl Sync for PermissionLevel
impl Unpin for PermissionLevel
impl UnwindSafe for PermissionLevel
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> 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
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<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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more