pub struct DependencyResolver { /* private fields */ }Expand description
Dependency resolver for batch package operations.
Provides a high-level API for resolving dependencies for multiple packages, handling batch operations, conflict detection, and dependency merging.
Implementations§
Source§impl DependencyResolver
impl DependencyResolver
Sourcepub fn new() -> Self
pub fn new() -> Self
What: Create a new dependency resolver with default configuration.
Inputs:
- (none)
Output:
- Returns a new
DependencyResolverwith default configuration.
Details:
- Uses
ResolverConfig::default()for configuration. - Default config: direct dependencies only, no optional/make/check deps, no AUR checking.
§Example
use arch_toolkit::deps::DependencyResolver;
let resolver = DependencyResolver::new();Sourcepub fn with_config(config: ResolverConfig) -> Self
pub fn with_config(config: ResolverConfig) -> Self
What: Create a resolver with custom configuration.
Inputs:
config: Custom resolver configuration.
Output:
- Returns a new
DependencyResolverwith the provided configuration.
Details:
- Allows customization of dependency resolution behavior.
§Example
use arch_toolkit::deps::DependencyResolver;
use arch_toolkit::types::dependency::ResolverConfig;
let config = ResolverConfig {
include_optdepends: true,
include_makedepends: false,
include_checkdepends: false,
max_depth: 0,
pkgbuild_cache: None,
check_aur: false,
};
let resolver = DependencyResolver::with_config(config);Sourcepub fn resolve_graph<P: DependencyMetadataProvider>(
&self,
packages: &[PackageRef],
provider: &P,
graph_config: DependencyGraphConfig,
) -> Result<DependencyGraphResolution>
pub fn resolve_graph<P: DependencyMetadataProvider>( &self, packages: &[PackageRef], provider: &P, graph_config: DependencyGraphConfig, ) -> Result<DependencyGraphResolution>
What: Resolve a bounded deterministic dependency graph through injected .SRCINFO metadata.
Inputs:
packages: Root package references to expand.provider: Mockable metadata provider returning verified raw.SRCINFOtext.graph_config: Explicit graph depth, node, timeout, and batch-concurrency bounds.
Output:
- Returns a graph with lexical nodes/edges and non-fatal structured diagnostics.
§Errors
Returns Err(ArchToolkitError::InvalidInput) when node, timeout, or provider batch bounds
are zero.
Details:
- This additive path preserves
resolveas the synchronous direct-only host resolver. - It is available with
depsalone and does not execute helpers, pacman, or network I/O. - Metadata is cached only for this call; rendering is available separately through
DependencyGraphResolution::render_tree.
Sourcepub fn resolve(&self, packages: &[PackageRef]) -> Result<DependencyResolution>
pub fn resolve(&self, packages: &[PackageRef]) -> Result<DependencyResolution>
What: Resolve dependencies for a list of packages.
Inputs:
packages: Slice ofPackageRefrecords to resolve dependencies for.
Output:
- Returns
Ok(DependencyResolution)with resolved dependencies, conflicts, and missing packages. - Returns
Err(ArchToolkitError)if resolution fails.
Details:
- Resolves ONLY direct dependencies (non-recursive) for each package.
- Merges duplicates by name, retaining the most severe status across all requesters.
- Detects conflicts between packages being installed and already installed packages.
- Sorts dependencies by priority (conflicts first, then missing, then to-install, then installed).
- Uses batch fetching for official packages to reduce pacman command overhead.
§Errors
Returns Err(ArchToolkitError::Parse) if pacman commands fail or output cannot be parsed.
Returns Err(ArchToolkitError::PackageNotFound) if required packages are not found.
§Example
use arch_toolkit::deps::DependencyResolver;
use arch_toolkit::{PackageRef, PackageSource};
let resolver = DependencyResolver::new();
let packages = vec![
PackageRef {
name: "firefox".into(),
version: "121.0".into(),
source: PackageSource::Official {
repo: "extra".into(),
arch: "x86_64".into(),
},
},
];
let result = resolver.resolve(&packages)?;
println!("Found {} dependencies", result.dependencies.len());