Skip to main content

refresh_explicit_cache_async

Function refresh_explicit_cache_async 

Source
pub async fn refresh_explicit_cache_async(
    mode: InstalledPackagesMode,
    cache: Option<&mut HashSet<String>>,
) -> Result<HashSet<String>>
Expand description

What: Query pacman for explicitly installed packages asynchronously and optionally update a cache.

Inputs:

  • mode: Filter mode determining which packages to query (LeafOnly or AllExplicit).
  • cache: Optional mutable reference to a HashSet<String> to update with results.

Output:

  • Returns a future that resolves to Result<HashSet<String>> containing explicitly installed package names.

Details:

  • Uses tokio::task::spawn_blocking to run the sync version in a blocking task.
  • If cache is provided, updates it with the results after the task completes.
  • The cache parameter must be Send and Sync to be used across async boundaries.

§Errors

Returns Err if the blocking task fails, otherwise returns the same result as the sync version.

§Example

use arch_toolkit::index::{refresh_explicit_cache_async, InstalledPackagesMode};
use std::collections::HashSet;

let mut cache = HashSet::new();
let packages = refresh_explicit_cache_async(InstalledPackagesMode::LeafOnly, Some(&mut cache)).await?;
println!("Found {} leaf packages", packages.len());