pub fn fetch_official_index() -> Result<OfficialIndex>Expand description
What: Fetch the official package index using pacman -Sl.
Inputs:
- None: Attempts to fetch via
pacman -Slcommand.
Output:
Ok(OfficialIndex)containing all official packages with name index rebuilt.Errif pacman is unavailable or output cannot be parsed.
Details:
- Uses
pacman -Slfor fast, local fetching (no network required). - Queries the default repositories (core, extra, multilib) only. On
derivative distros (
EndeavourOS,CachyOS, …) combinedetect_enabled_reposwithfetch_official_index_for_reposinstead. - For API fallback, use
fetch_official_index_async()instead. - Rebuilds name index after fetching for O(1) lookups.
§Errors
- Returns
Err(ArchToolkitError::Parse)if pacman is unavailable or output cannot be parsed.
§Example
use arch_toolkit::index::fetch_official_index;
let index = fetch_official_index()?;
println!("Found {} official packages", index.pkgs.len());