nix

Trait NixPath

source
pub trait NixPath {
    // Required methods
    fn is_empty(&self) -> bool;
    fn len(&self) -> usize;
    fn with_nix_path<T, F>(&self, f: F) -> Result<T>
       where F: FnOnce(&CStr) -> T;
}
Expand description

Common trait used to represent file system paths by many Nix functions.

Required Methods§

source

fn is_empty(&self) -> bool

Is the path empty?

source

fn len(&self) -> usize

Length of the path in bytes

source

fn with_nix_path<T, F>(&self, f: F) -> Result<T>
where F: FnOnce(&CStr) -> T,

Execute a function with this path as a CStr.

Mostly used internally by Nix.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NixPath for str

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

fn with_nix_path<T, F>(&self, f: F) -> Result<T>
where F: FnOnce(&CStr) -> T,

source§

impl NixPath for CStr

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

fn with_nix_path<T, F>(&self, f: F) -> Result<T>
where F: FnOnce(&CStr) -> T,

source§

impl NixPath for OsStr

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

fn with_nix_path<T, F>(&self, f: F) -> Result<T>
where F: FnOnce(&CStr) -> T,

source§

impl NixPath for Path

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

fn with_nix_path<T, F>(&self, f: F) -> Result<T>
where F: FnOnce(&CStr) -> T,

source§

impl NixPath for PathBuf

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

fn with_nix_path<T, F>(&self, f: F) -> Result<T>
where F: FnOnce(&CStr) -> T,

source§

impl NixPath for [u8]

source§

fn is_empty(&self) -> bool

source§

fn len(&self) -> usize

source§

fn with_nix_path<T, F>(&self, f: F) -> Result<T>
where F: FnOnce(&CStr) -> T,

Implementors§