pub struct Permissions(/* private fields */);Expand description
Represents the permissions of a file or directory.
The permissions are divided into three groups: user, group, and others. Each group has three permissions: read, write, and execute.
§Examples
use file_system::{Permissions, Permission, Special};
let user = Permission::Read; // Read only
let group = Permission::Write; // Write only
let others = Permission::Execute; // Execute only
let special = Special::empty();
let permissions = Permissions::new(user, group, others, special);
assert_eq!(permissions.get_user(), user);
assert_eq!(permissions.get_group(), group);
assert_eq!(permissions.get_others(), others);
assert_eq!(permissions.get_special(), special);Implementations§
Source§impl Permissions
impl Permissions
pub const NONE: Self
pub const ALL_FULL: Self
pub const ALL_READ_WRITE: Self
pub const USER_FULL: Self
pub const USER_READ_WRITE: Self
pub const EXECUTABLE: Self
pub const FILE_DEFAULT: Self
pub const DIRECTORY_DEFAULT: Self
Sourcepub const SHARED_DIRECTORY: Self
pub const SHARED_DIRECTORY: Self
World-writable directory where only an entry’s owner may remove or rename it, like Unix mode 1777.
pub const DEVICE_DEFAULT: Self
Sourcepub const PRIVILEGED_DEVICE: Self
pub const PRIVILEGED_DEVICE: Self
Device whose writes are reserved to its owner (root when the runtime mounts it): owner read-write, group and others read-only. Used for device nodes whose write commands change system state, like the real-time clock.
Sourcepub const fn new(
user: Permission,
group: Permission,
others: Permission,
special: Special,
) -> Self
pub const fn new( user: Permission, group: Permission, others: Permission, special: Special, ) -> Self
Creates a new permission.
Sourcepub const fn new_default(type: Kind) -> Self
pub const fn new_default(type: Kind) -> Self
Creates a new permission with read access for user. No access for group and others.
Sourcepub fn set_user(self, user: Permission) -> Self
pub fn set_user(self, user: Permission) -> Self
Sets the permission for the user.
Sourcepub fn set_group(self, group: Permission) -> Self
pub fn set_group(self, group: Permission) -> Self
Sets the permission for the group.
Sourcepub fn set_others(self, others: Permission) -> Self
pub fn set_others(self, others: Permission) -> Self
Sets the permission for others.
Sourcepub fn set_special(self, special: Special) -> Self
pub fn set_special(self, special: Special) -> Self
Sets the special permissions.
Sourcepub fn get_user(&self) -> Permission
pub fn get_user(&self) -> Permission
Gets the permission for the user.
Sourcepub fn get_group(&self) -> Permission
pub fn get_group(&self) -> Permission
Gets the permission for the group.
Sourcepub fn get_others(&self) -> Permission
pub fn get_others(&self) -> Permission
Gets the permission for others.
Sourcepub fn get_special(&self) -> Special
pub fn get_special(&self) -> Special
Gets the special permissions.
Sourcepub const fn from_octal(unix: u16) -> Option<Self>
pub const fn from_octal(unix: u16) -> Option<Self>
Converts the permission to a Unix permission.
Trait Implementations§
Source§impl Clone for Permissions
impl Clone for Permissions
Source§fn clone(&self) -> Permissions
fn clone(&self) -> Permissions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Permissions
impl Debug for Permissions
Source§impl Display for Permissions
impl Display for Permissions
Source§impl From<(Permission, Permission, Permission)> for Permissions
impl From<(Permission, Permission, Permission)> for Permissions
Source§fn from(value: (Permission, Permission, Permission)) -> Self
fn from(value: (Permission, Permission, Permission)) -> Self
Source§impl From<(Permission, Permission, Permission, Special)> for Permissions
impl From<(Permission, Permission, Permission, Special)> for Permissions
Source§fn from(value: (Permission, Permission, Permission, Special)) -> Self
fn from(value: (Permission, Permission, Permission, Special)) -> Self
Source§impl PartialEq for Permissions
impl PartialEq for Permissions
Source§fn eq(&self, other: &Permissions) -> bool
fn eq(&self, other: &Permissions) -> bool
self and other values to be equal, and is used by ==.