Skip to main content

fetch_official_index

Function fetch_official_index 

Source
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 -Sl command.

Output:

  • Ok(OfficialIndex) containing all official packages with name index rebuilt.
  • Err if pacman is unavailable or output cannot be parsed.

Details:

  • Uses pacman -Sl for fast, local fetching (no network required).
  • Queries the default repositories (core, extra, multilib) only. On derivative distros (EndeavourOS, CachyOS, …) combine detect_enabled_repos with fetch_official_index_for_repos instead.
  • 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());