pub struct PermissionSet { /* private fields */ }Expand description
A bitmask-based set of granted permissions, optionally combined with fine-grained filesystem path restrictions.
Operations return Self by value for builder-pattern chaining.
Implementations§
Source§impl PermissionSet
impl PermissionSet
Sourcepub fn with_all() -> Self
pub fn with_all() -> Self
Create a set with all known permissions granted (no path restrictions).
Sourcepub fn grant(self, flag: u32) -> Self
pub fn grant(self, flag: u32) -> Self
Grant the given permission flag(s), returning the updated set.
Sourcepub fn revoke(self, flag: u32) -> Self
pub fn revoke(self, flag: u32) -> Self
Revoke the given permission flag(s), returning the updated set.
Sourcepub fn has(&self, flag: u32) -> bool
pub fn has(&self, flag: u32) -> bool
Test whether the given permission flag(s) are all granted.
Sourcepub fn allow_path(self, path: impl Into<PathBuf>) -> Self
pub fn allow_path(self, path: impl Into<PathBuf>) -> Self
Add a path to the filesystem allow-list.
When the allow-list is non-empty, only paths that are equal to or
are descendants of an allowed path may be accessed (requires
PERM_FILESYSTEM to be set as well).
The path is stored as-is (no canonicalisation is performed here; canonicalise before calling if required).
Sourcepub fn allowed_paths(&self) -> &[PathBuf]
pub fn allowed_paths(&self) -> &[PathBuf]
Return the filesystem path allow-list.
Sourcepub fn is_path_allowed(&self, path: &Path) -> bool
pub fn is_path_allowed(&self, path: &Path) -> bool
Check whether path is permitted by the current allow-list rules.
Returns true if:
PERM_FILESYSTEMis not set → always false (filesystem denied), orPERM_FILESYSTEMis set AND the allow-list is empty → always true, orPERM_FILESYSTEMis set ANDpathstarts with any allowed path entry.
Trait Implementations§
Source§impl Clone for PermissionSet
impl Clone for PermissionSet
Source§fn clone(&self) -> PermissionSet
fn clone(&self) -> PermissionSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PermissionSet
impl Debug for PermissionSet
Source§impl Default for PermissionSet
impl Default for PermissionSet
Source§impl PartialEq for PermissionSet
impl PartialEq for PermissionSet
impl Eq for PermissionSet
impl StructuralPartialEq for PermissionSet
Auto Trait Implementations§
impl Freeze for PermissionSet
impl RefUnwindSafe for PermissionSet
impl Send for PermissionSet
impl Sync for PermissionSet
impl Unpin for PermissionSet
impl UnsafeUnpin for PermissionSet
impl UnwindSafe for PermissionSet
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<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