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:
find_candidates/find_candidates_with_path_env— discovery only, returns candidates in deterministic (PATH discovery) order.rank_candidates— sorts a candidate slice in place by aScoringPolicy.resolve_stable_path— the convenience composition of find + rank that returns the single best candidate.
Structs§
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_candidatesand related functions. - PathTag
- Observed properties of a candidate path.
- Scoring
Policy - Policy for ranking candidates returned by
rank_candidates.
Functions§
- find_
candidates - Discover all candidate locations for
binary, searching the processPATH. - find_
candidates_ with_ path_ env - Discover all candidate locations for
binary, usingpath_envas the PATH to search. - rank_
candidates - Sort
candidatesin place by score descending, with PATH discovery order ascending as a deterministic tie-breaker. - resolve_
stable_ path - Resolve the single best candidate for
binaryunderpolicy.