Trait NormalizeStorePath

Source
pub trait NormalizeStorePath<P: AsRef<Path>> {
    type Error;

    // Required method
    fn normalize(&self, path: P) -> Result<PathBuf, Self::Error>;

    // Provided method
    fn rel_from_root(&self, path: P) -> Result<PathBuf, Self::Error> { ... }
}
Expand description

A trait containing a path normalization method, to normalize paths in an Ekala store relative to its root.

Required Associated Types§

Source

type Error

The error type returned by the NormalizeStorePath::normalize function.

Required Methods§

Source

fn normalize(&self, path: P) -> Result<PathBuf, Self::Error>

Normalizes a given path to be relative to the store root.

This function takes a path (relative or absolute) and attempts to normalize it relative to the store root, based on the current working directory within the store system.

§Behavior:
  • For relative paths (e.g., “foo/bar” or “../foo”):

    • Interpreted as relative to the current working directory within the repository.
    • Computed relative to the repository root.
  • For absolute paths (e.g., “/foo/bar”):

    • Treated as if the repository root is the filesystem root.
    • The leading slash is ignored, and the path is considered relative to the repo root.

Provided Methods§

Source

fn rel_from_root(&self, path: P) -> Result<PathBuf, Self::Error>

Same as normalization but gives the relative difference between the path given and the root of the store (e.g. foo/bar -> ../..). Path must be an ancestor of the store root or this will fail.

Implementations on Foreign Types§

Source§

impl<P: AsRef<Path>> NormalizeStorePath<P> for Repository

Implementors§