pub fn refresh_installed_cache(
cache: Option<&mut HashSet<String>>,
) -> Result<HashSet<String>>Expand description
What: Query pacman for all installed packages and optionally update a cache.
Inputs:
cache: Optional mutable reference to aHashSet<String>to update with results.
Output:
- Returns
Ok(HashSet<String>)containing all installed package names. - Returns
Ok(HashSet::new())on failure (graceful degradation).
Details:
- Uses
pacman -Qqto query the local database. - If
cacheis provided, updates it with the results. - Sets
LC_ALL=CandLANG=Cfor consistent locale-independent output. - Logs errors for diagnostics but returns empty set to avoid blocking operations.
§Errors
This function does not return errors - it gracefully degrades by returning an empty set.
Errors are logged using tracing::error for diagnostics.
§Example
use arch_toolkit::index::refresh_installed_cache;
use std::collections::HashSet;
let mut cache = HashSet::new();
let packages = refresh_installed_cache(Some(&mut cache)).unwrap();
println!("Found {} installed packages", packages.len());