Skip to main content

Crate stable_which

Crate stable_which 

Source
Expand description

Evaluate binary path stability and find stable PATH candidates.

This library analyzes binary paths, tags them with observed attributes (version manager, build output, ephemeral, shim, etc.), judges their Durability (whether a path can be pinned into a service definition), and ranks them to find the most suitable candidate for use in service registration, configuration files, or scripts.

§Quick Start

use stable_which::{find_candidates, rank_candidates, ScoringPolicy};
use std::path::Path;

let mut candidates = find_candidates(Path::new("jj")).unwrap();
rank_candidates(&mut candidates, ScoringPolicy::SameBinary);
println!("Best: {}", candidates[0].path().display());

§API layering

The public surface separates three concerns:

Structs§

Candidate
A discovered location for a binary, with the observed PathTags that describe it.

Enums§

Durability
Whether a path string keeps pointing at the same (logical) target across rebuild / upgrade / reboot.
Error
Errors that can be returned by find_candidates and related functions.
PathTag
Observed properties of a candidate path.
ScoringPolicy
Policy for ranking candidates returned by rank_candidates.

Functions§

find_candidates
Discover all candidate locations for binary, searching the process PATH.
find_candidates_with_path_env
Discover all candidate locations for binary, using path_env as the PATH to search.
rank_candidates
Sort candidates in place by score descending, with PATH discovery order ascending as a deterministic tie-breaker.
resolve_stable_path
Resolve the single best candidate for binary under policy.