Struct cchmod::Mode [−][src]
Expand description
File system object mode.
Fields
user: Perm
Permission set for the owning user.
group: Perm
Permission set for the group.
other: Perm
Permission set for all other users.
Implementations
Create a Mode
from its octal form, returning ParseError
if the input is invalid.
Examples
use cchmod::{Mode, Perm, ParseError};
assert_eq!(
Mode::new(Perm::new(true, true, true),
Perm::new(true, false, true),
Perm::new(true, false, true)),
Mode::from_num("755").unwrap()
);
assert_eq!(
ParseError::UnexpectedChar { pos: 3, c: '8', expected: None },
Mode::from_num("6008").unwrap_err()
);
Create a Mode
from its symbolic form, returning ParseError
if the input is invalid.
Examples
use cchmod::{Mode, Perm, ParseError};
assert_eq!(
Mode::new(Perm::new(true, true, true),
Perm::new(true, false, true),
Perm::new(true, false, true)),
Mode::from_sym("rwxr-xr-x").unwrap()
);
assert_eq!(
ParseError::UnexpectedEoi { pos: 6 },
Mode::from_sym("rwxr-x").unwrap_err()
);
assert_eq!(
ParseError::UnexpectedChar { pos: 9, c: 'r', expected: None },
Mode::from_sym("rwxr-xr-xr").unwrap_err()
);
Compute the diff (ModeDiff
) between two modes.
Examples
use cchmod::{Mode, ModeDiff, PermDiff, DiffOp::*};
let a = Mode::from_num("777").unwrap();
let b = Mode::from_num("644").unwrap();
assert_eq!(
ModeDiff {
user: PermDiff { read: Same, write: Same, execute: Minus },
group: PermDiff { read: Same, write: Minus, execute: Minus },
other: PermDiff { read: Same, write: Minus, execute: Minus },
},
a.diff(&b)
);