Trait fs_mistrust::anon_home::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§
sourcefn anonymize_home(&self) -> AnonHomePath<'_>
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!();