Skip to main content

Durability

Enum Durability 

Source
#[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)

  1. NotDurable is decided first: versioned-install / ephemeral / build-output / project-local patterns.
  2. 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 is Durable.
  3. Otherwise Unknown (treated as not-durable by Candidate::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 judged Durable yet 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-profile is 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 to Unknown (safe side).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source§

fn clone(&self) -> Durability

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Durability

Source§

impl Debug for Durability

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Durability

Source§

impl PartialEq for Durability

Source§

fn eq(&self, other: &Durability) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Durability

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.