Struct cchmod::Mode[][src]

pub struct Mode {
    pub user: Perm,
    pub group: Perm,
    pub other: Perm,
}
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 new Mode.

Get the octal representation the Mode.

Examples
use cchmod::{Mode, Perm};

let m = Mode::new(Perm::new(true, true, true),
                  Perm::new(true, false, true),
                  Perm::new(true, false, true));

assert_eq!("755", m.as_num());

Get the symbolic representation the Mode.

Examples
use cchmod::{Mode, Perm};

let m = Mode::new(Perm::new(true, true, true),
                  Perm::new(true, false, true),
                  Perm::new(true, false, true));

assert_eq!("rwxr-xr-x", m.as_sym());

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)
);

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.