pub fn is_explicit(
name: &str,
mode: InstalledPackagesMode,
cache: Option<&HashSet<String>>,
) -> boolExpand description
What: Check if a package is explicitly installed, using cache if provided or querying pacman directly.
Inputs:
name: Package name to check.mode: Filter mode for query type (LeafOnlyorAllExplicit).cache: Optional reference to aHashSet<String>containing explicit package names.
Output:
- Returns
trueif the package is explicitly installed,falseotherwise.
Details:
- If
cacheis provided, checks membership in the cache (O(1) lookup). - If
cacheisNone, queries pacman directly using the appropriate command for the mode. - Gracefully degrades: returns
falseon error.
ยงExample
use arch_toolkit::index::{is_explicit, InstalledPackagesMode};
use std::collections::HashSet;
let cache = HashSet::from(["vim".to_string(), "git".to_string()]);
assert!(is_explicit("vim", InstalledPackagesMode::AllExplicit, Some(&cache)));
assert!(!is_explicit("nonexistent", InstalledPackagesMode::AllExplicit, Some(&cache)));