Slugify and deterministic collation
State: open/verified · Kind: module · Audience: system
Summary
Section titled “Summary”- NFKD-normalizing slugify plus a deterministic, locale-independent collation, so titles become stable filenames and cross-machine sorts never depend on ICU or the host locale.
- Extracted from determined-vault and promoted to a tier-1 shared crate.
Statement
Section titled “Statement”slugify and slugify_with turn a title into a filesystem-safe slug: NFKD-decompose, drop
combining marks, fold non-alphanumerics to a separator, collapse, trim and cap length. café
becomes cafe rather than colliding with an unaccented twin. compare, compare_paths and
path_sort_key are a portable substitute for localeCompare: case-insensitive, accent-folded, ties
broken by raw bytes, so two machines never disagree on an order. The vault crates rely on this for
hashed and rendered output such as backup tree entries, the parity manifest and digest tie-breaks.
What it provides
Section titled “What it provides”slugify(input)andslugify_with(input, SlugOptions), with options for max length and apostrophes.compare(a, b): deterministic string ordering.compare_paths(a, b): segment-wise path comparison with the same collation.path_sort_key(path): a precomputed key forsort_by_cached_keygiving the same order ascompare_paths.
Underlying implementation
Section titled “Underlying implementation”packages/rust/slug/src/lib.rs.- Consumers:
solutions/determined/crates/determined-{vault,notes,authoring,index,sync,photos,backup},packages/rust/wikilink,packages/rust/vault-transform.
Locations
Section titled “Locations”packages/rust/slug/packages/rust/slug/src/lib.rs#slugifypackages/rust/slug/src/lib.rs#comparepackages/rust/slug/src/lib.rs#compare_pathspackages/rust/slug/src/lib.rs#path_sort_key