[][src]Crate umask

A light utility helping with unix mode representation, with strong types to avoid misusing constants.

The Mode struct implements Display and prints as "rwxrwxrwx"

use umask::*;

// You can build from a number:
assert_eq!("rw-r--r--", Mode::from(0b110100100).to_string());
assert_eq!("rw-r--r--", Mode::from(0o644).to_string());

// You may use `|` to combine class permissions:
let mu = Mode::from(0o640);
let mo = Mode::from(0o044);
assert_eq!("rw-r--r--", (mu | mo).to_string());
assert_eq!("---r-----", (mu & mo).to_string());

// You can use more semantic constructs:
let m = Mode::all()
    .without(ALL_EXEC);
assert_eq!("rw-rw-rw-", m.to_string());
let mut m = Mode::new()
    .with_class_perm(ALL, READ)
    .with_class_perm(USER, WRITE);
assert_eq!("rw-r--r--", m.to_string());
// (semantic functions can be used in const declarations)

// Or
m |= ALL_EXEC;
assert_eq!("rwxr-xr-x", m.to_string());
let m = ALL_READ | USER_WRITE;
assert_eq!("rw-r--r--", m.to_string());

Structs

Mode

Constants

ALL
ALL_EXEC
ALL_READ
ALL_WRITE
EXEC
GROUP
GROUP_EXEC
GROUP_READ
GROUP_WRITE
OTHERS
OTHERS_EXEC
OTHERS_READ
OTHERS_WRITE
READ
USER
USER_EXEC
USER_READ
USER_WRITE
WRITE

Type Definitions

Class
Permission