Calculate

Trait Calculate 

Source
pub trait Calculate {
    // Required methods
    fn home_dir(&self) -> Result<Cow<'_, Path>>;
    fn as_absolute_path(&self) -> Result<Cow<'_, Path>>;
    fn relative_root_with(&self, path_b: &Path) -> Result<Cow<'_, Path>>;
    fn related_to(&self, src_path: &Path) -> Result<Cow<'_, Path>>;
}
Expand description

Let Path and PathBuf have some path calculate methods.

Required Methods§

Source

fn home_dir(&self) -> Result<Cow<'_, Path>>

Get current env’s home_dir if it exist.

Source

fn as_absolute_path(&self) -> Result<Cow<'_, Path>>

Get the absolute path, even if the path is not exist.

Source

fn relative_root_with(&self, path_b: &Path) -> Result<Cow<'_, Path>>

Get a relative root path betwwen two pathes.

Source

fn related_to(&self, src_path: &Path) -> Result<Cow<'_, Path>>

Get dst_path’s relative path from the src_path.

Implementations on Foreign Types§

Source§

impl Calculate for Path

Source§

fn home_dir(&self) -> Result<Cow<'_, Path>>

Source§

fn as_absolute_path(&self) -> Result<Cow<'_, Path>>

Source§

fn relative_root_with(&self, path_b: &Path) -> Result<Cow<'_, Path>>

Source§

fn related_to(&self, src_path: &Path) -> Result<Cow<'_, Path>>

Source§

impl Calculate for PathBuf

Source§

fn home_dir(&self) -> Result<Cow<'_, Path>>

Source§

fn as_absolute_path(&self) -> Result<Cow<'_, Path>>

Source§

fn relative_root_with(&self, path_b: &Path) -> Result<Cow<'_, Path>>

Source§

fn related_to(&self, src_path: &Path) -> Result<Cow<'_, Path>>

Implementors§