DependencyResolver

Struct DependencyResolver 

Source
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

Source

pub fn new() -> Self

What: Create a new dependency resolver with default configuration.

Inputs:

  • (none)

Output:

  • Returns a new DependencyResolver with 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();
Source

pub fn with_config(config: ResolverConfig) -> Self

What: Create a resolver with custom configuration.

Inputs:

  • config: Custom resolver configuration.

Output:

  • Returns a new DependencyResolver with 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);
Source

pub fn resolve(&self, packages: &[PackageRef]) -> Result<DependencyResolution>

What: Resolve dependencies for a list of packages.

Inputs:

  • packages: Slice of PackageRef records 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());

Trait Implementations§

Source§

impl Default for DependencyResolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more