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_type, Permission_type, Special_type};
let user = Permission_type::new(true, false, false); // Read only
let group = Permission_type::new(false, true, false); // Write only
let others = Permission_type::new(false, false, true); // Execute only
let special = Special_type::new(true, false, true); // Sticky and set user identifier
let permissions = Permissions_type::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
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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Permissions
impl Debug for Permissions
Source§impl Display for Permissions
impl Display for Permissions
Source§impl PartialEq for Permissions
impl PartialEq for Permissions
impl Copy for Permissions
impl Eq for Permissions
impl StructuralPartialEq for Permissions
Auto Trait Implementations§
impl Freeze for Permissions
impl RefUnwindSafe for Permissions
impl Send for Permissions
impl Sync for Permissions
impl Unpin for Permissions
impl UnwindSafe for Permissions
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
Mutably borrows from an owned value. Read more