pub struct Perm {
pub read: bool,
pub write: bool,
pub execute: bool,
}Expand description
File system object permissions.
See perm for predefined constant values.
Fields§
§read: boolFlag indicating whether read permission is granted.
write: boolFlag indicating whether write permission is granted.
execute: boolFlag indicating whether execute permission is granted.
Implementations§
Source§impl Perm
impl Perm
Sourcepub fn as_sym_full(&self) -> String
pub fn as_sym_full(&self) -> String
Sourcepub fn from_num(num: &str) -> Result<Self, ParseError>
pub fn from_num(num: &str) -> Result<Self, ParseError>
Create a Perm from its octal form, returning ParseError if the input is invalid.
§Examples
use cchmod::{Perm, ParseError};
assert_eq!(Perm::new(true, true, true), Perm::from_num("7").unwrap());
assert_eq!(Perm::new(true, false, false), Perm::from_num("4").unwrap());
assert_eq!(
ParseError::UnexpectedEoi { pos: 0 },
Perm::from_num("").unwrap_err()
);
assert_eq!(
ParseError::UnexpectedChar {
pos: 0,
c: '8',
expected: Some(vec!['0', '1', '2', '3', '4', '5', '6', '7'])
},
Perm::from_num("8").unwrap_err()
);Sourcepub fn from_sym_full(sym: &str) -> Result<Self, ParseError>
pub fn from_sym_full(sym: &str) -> Result<Self, ParseError>
Create a Perm from its symbolic form, returning ParseError if the input is invalid.
§Examples
use cchmod::{Perm, ParseError};
assert_eq!(Perm::new(true, true, true), Perm::from_sym_full("rwx").unwrap());
assert_eq!(Perm::new(true, false, false), Perm::from_sym_full("r--").unwrap());
assert_eq!(
ParseError::UnexpectedEoi { pos: 2 },
Perm::from_sym_full("rw").unwrap_err()
);
assert_eq!(
ParseError::UnexpectedChar { pos: 3, c: 'r', expected: None },
Perm::from_sym_full("rwxr").unwrap_err()
);Trait Implementations§
impl StructuralPartialEq for Perm
Auto Trait Implementations§
impl Freeze for Perm
impl RefUnwindSafe for Perm
impl Send for Perm
impl Sync for Perm
impl Unpin for Perm
impl UnsafeUnpin for Perm
impl UnwindSafe for Perm
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