Skip to main content

path_identity_key

Function path_identity_key 

Source
pub fn path_identity_key(
    path: impl AsRef<Path>,
    options: PathIdentityOptions,
) -> Result<String, PathError>
Expand description

Produce a deterministic path identity / comparison key.

§Filesystem access

Only when resolve_existing_symlinks is true (may call canonicalize). Does not expand environment variables. Does not use a cache.

§Returns

A String unsuitable for direct filesystem access. It is a comparison key only.

§Platform behavior

  • Windows default case folding is ASCII-lowercase.
  • Linux default preserves case.
  • Symlink resolution changes identity semantics when enabled.
  • Unicode normalization is not applied unless the unicode feature helpers are used separately.

§Examples

use path_rs::{path_identity_key, CaseNormalization, PathIdentityOptions};

let opts = PathIdentityOptions {
    case: CaseNormalization::AsciiLowercase,
    ..PathIdentityOptions::default()
};
let a = path_identity_key(r"C:\Users\Floris\Repo", opts).unwrap();
let b = path_identity_key(r"c:/users/floris/repo/", opts).unwrap();
assert_eq!(a, b);