pub fn get_installed_versions() -> HashMap<String, String>Expand description
What: Retrieve the versions of all installed packages in one pacman invocation.
Inputs:
- (none): Invokes
pacman -Qto list every installed package with its version.
Output:
- Map from package name to installed version (revision suffix stripped,
e.g.
1.2.3-1->1.2.3, matchingget_installed_version). - Empty map on failure (graceful degradation).
Details:
- One subprocess for the whole system — use this instead of calling
get_installed_versionin a loop (e.g. build-preflight analysis of a long dependency list). - Sets
LC_ALL=CandLANG=Cfor consistent locale-independent output.
§Example
use arch_toolkit::deps::get_installed_versions;
let versions = get_installed_versions();
if let Some(version) = versions.get("pacman") {
println!("pacman {version}");
}