Skip to main content

PathExt

Trait PathExt 

Source
pub trait PathExt {
    // Required method
    fn anonymize_home(&self) -> AnonHomePath<'_>;
}
Available on crate feature anon_home only.
Expand description

An extension trait for Path.

Required Methods§

Source

fn anonymize_home(&self) -> AnonHomePath<'_>

If this is a path within our home directory, try to replace the home directory component with a symbolic reference to our home directory.

This function can be useful for outputting paths while reducing the risk of exposing usernames in the log.

§Examples
use std::path::{Path,PathBuf};
use fs_mistrust::anon_home::PathExt as _;

let path = PathBuf::from("/home/arachnidsGrip/.config/arti.toml");
assert_eq!(path.anonymize_home().to_string(),
           "${HOME}/.config/arti.toml");
panic!();

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PathExt for Path

An extension trait for Path.

Source§

fn anonymize_home(&self) -> AnonHomePath<'_>

If this is a path within our home directory, try to replace the home directory component with a symbolic reference to our home directory.

This function can be useful for outputting paths while reducing the risk of exposing usernames in the log.

§Examples
use std::path::{Path,PathBuf};
use fs_mistrust::anon_home::PathExt as _;

let path = PathBuf::from("/home/arachnidsGrip/.config/arti.toml");
assert_eq!(path.anonymize_home().to_string(),
           "${HOME}/.config/arti.toml");
panic!();

Implementors§