UNIXPermissionsExt

BUILD crates.io docs.rs

A trivial trait bringing missing functions that are not exposed by std::os::unix::fs::PermissionsExt to std::fs::Permissions on UNIX platforms.

```rust pub trait UNIXPermissionsExt { fn setuid(&self) -> bool; fn setgid(&self) -> bool; fn stickybit(&self) -> bool; fn readablebyowner(&self) -> bool; fn writablebyowner(&self) -> bool; fn executablebyowner(&self) -> bool; fn readablebygroup(&self) -> bool; fn writablebygroup(&self) -> bool; fn executablebygroup(&self) -> bool; fn readablebyother(&self) -> bool; fn writablebyother(&self) -> bool; fn executableby_other(&self) -> bool; fn stringify(&self) -> String; }

impl UNIXPermissionsExt for Permissions { ... } ```

Usage

  1. Add it to your dependency:

    shell $ cd $YOUR_PROJECT $ cargo add unix_permissions_ext

  2. Import this trait and use it just like you are using the standard library!

    ```rust use std::fs::metadata; use unixpermissionsext::UNIXPermissionsExt;

    let metadata = metadata("/usr/bin/passwd").expect("can not fetch metadata"); let permission = metadata.permissions();

    assert!(permission.set_uid()); println!("Permission: {}", permission.stringify()); ```

  3. To use these functions directly with the mode_t type, consider importing raw_fn module:

    rust use unix_permissions_ext::raw_fn::*;

Contributing

Contributions of all forms are welcome, feel free to file an issue or make a pull request!

Test before your commit

  1. Pass the tests

    shell $ cargo test

  2. Format your code

    shell $ cargo fmt