#[non_exhaustive]pub enum Durability {
Durable,
NotDurable,
Unknown,
}Expand description
Whether a path string keeps pointing at the same (logical) target across rebuild / upgrade / reboot.
This is a durable-to-pin judgement: a Durable
path may be baked into a launchd plist / systemd unit and is expected to
survive upgrades and reboots. Judgement is per candidate — for the same
binary, the reference path (/opt/homebrew/bin/git) can be
Durable while its canonical realpath
(/opt/homebrew/Cellar/git/2.44.0/bin/git) is
NotDurable.
§Judging model (allow-list)
NotDurableis decided first: versioned-install / ephemeral / build-output / project-local patterns.- Otherwise, if the path is under a known durable location (the
“environment-wide reference surfaces”: standard system bins, profile
bins matched by their exact structure, shims at standard HOME-anchored
locations, and HOME-anchored direct-install dirs such as
~/.cargo/bin), it isDurable. - Otherwise
Unknown(treated as not-durable byCandidate::is_stable).
User dropbox directories (~/bin, ~/.local/bin) are deliberately not
in the durable allow-list: they mix shebang-embedded scripts and versioned
symlinks, so they fall through to Unknown. ~/.cargo/bin is not such a
dropbox: cargo install overwrites the binary in place at the same path
on every install/upgrade (no per-tool versioned symlink), so it is
included in the allow-list.
§Platform support
The durable location allow-list (step 2) is Unix-only: all entries in
[DURABLE_DIRECT_DIRS] and the /etc/profiles/per-user/<user>/bin/<file>
shape are Unix absolute paths (/usr/bin, /opt/homebrew/bin, etc.).
On Windows, Path::is_absolute returns false for these Unix paths
(no drive letter), so [is_durable_direct_dir] and
[is_etc_profiles_per_user_bin] always return false.
As a result, on Windows all paths that do not match a NotDurable
pattern fall through to Unknown (the safe side).
Windows-native durable surfaces (C:\Windows\System32, scoop/chocolatey/
winget bin directories, PowerShell profile paths, etc.) are not yet in
the allow-list and are planned for 0.5.x. See docs/issue/ for the
tracking issue.
§Known limitations
Judgement is path-string based and cannot detect:
- shebang-embedded versioned dependencies: e.g. a script in a standard
reference surface whose shebang points at a versioned interpreter
(
cpython@<ver>). Such a path may be judgedDurableyet break on upgrade. This is why shebang-prone user dropboxes are excluded from the allow-list (see above), but the case cannot be ruled out entirely. - environment-dependent paths: e.g.
~/.nix-profileis alive in some environments and dead in others; durability cannot be confirmed without inspecting the realpath. - non-UTF-8 paths: pattern matching goes through
Path::to_string_lossy, so a path containing non-UTF-8 bytes in a matched segment may compare unexpectedly; such paths typically fall through toUnknown(safe side).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Durable
The path string keeps pointing at the same entity (or same logical target) across rebuild / upgrade / reboot.
NotDurable
Versioned-install / ephemeral / build-output / project-local etc.; baking this path into a service definition can break it.
Unknown
Matched neither a known durable nor a known not-durable pattern; cannot decide (safe side = treated as not-durable).
Trait Implementations§
Source§impl Clone for Durability
impl Clone for Durability
Source§fn clone(&self) -> Durability
fn clone(&self) -> Durability
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Durability
Source§impl Debug for Durability
impl Debug for Durability
impl Eq for Durability
Source§impl PartialEq for Durability
impl PartialEq for Durability
Source§fn eq(&self, other: &Durability) -> bool
fn eq(&self, other: &Durability) -> bool
self and other values to be equal, and is used by ==.