## Resolver

# Struct Resolver

Source

    pub struct Resolver<'a, 'b, H = Handle> {Show 14 fields
        pub(crate) alpm: &'a Alpm,
        pub(crate) repos: Vec<PkgbuildRepo<'a>>,
        pub(crate) resolved: HashSet<String>,
        pub(crate) cache: &'b mut Cache,
        pub(crate) stack: Vec<DepMissing>,
        pub(crate) raur: &'b H,
        pub(crate) actions: Actions<'a>,
        pub(crate) seen: HashSet<String>,
        pub(crate) seen_target: HashSet<String>,
        pub(crate) flags: Flags,
        pub(crate) aur_namespace: Option<String>,
        pub(crate) provider_callback: Callback<dyn Fn(&str, &[&str]) -> usize + 'static>,
        pub(crate) group_callback: Callback<dyn Fn(&[Group<'a>]) -> Vec<&'a Package> + 'static>,
        pub(crate) is_devel: Callback<dyn Fn(&str) -> bool + 'static>,
    }

Expand description

Resolver is the main type for resolving dependencies

Given a list of targets of either repo or AUR packages it will resolve the dependencies needed to install them.

This resolver assumes all the repo packages will be installed first, then each base is built and installed together.

aur-depends will try to solve dependnecies using the minimum ammount of AUR RPC requests.

Resolving is done via the AUR RPC. No packages are downloaded.

## §Example

    use std::collections::HashSet;
    use alpm::Alpm;
    use raur::Handle;

    use aur_depends::{Flags, Resolver};

    let alpm = Alpm::new("/", "/var/lib/pacman")?;
    let raur = Handle::default();
    let mut cache = HashSet::new();
    let resolver = Resolver::new(&alpm, Vec::new(), &mut cache, &raur, Flags::aur());
    let actions = resolver.resolve_targets(&["discord-canary", "spotify"]).await?;

    for install in &actions.install {
        println!("install: {}", install.pkg.name())
    }

    for build in actions.iter_build_pkgs() {
        println!("build: {}", build.pkg.name)
    }

## Fields§

§`alpm: &'a Alpm`§`repos: Vec<PkgbuildRepo<'a>>`§`resolved: HashSet<String>`§`cache: &'b mut Cache`§`stack: Vec<DepMissing>`§`raur: &'b H`§`actions: Actions<'a>`§`seen: HashSet<String>`§`seen_target: HashSet<String>`§`flags: Flags`§`aur_namespace: Option<String>`§`provider_callback: Callback<dyn Fn(&str, &[&str]) -> usize + 'static>`§`group_callback: Callback<dyn Fn(&[Group<'a>]) -> Vec<&'a Package> + 'static>`§`is_devel: Callback<dyn Fn(&str) -> bool + 'static>`

## Implementations§

Source§

### impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>

Source

#### pub fn provider_callback<F: Fn(&str, &[&str]) -> usize + 'static>( self, f: F, ) -> Self

Set the provider callback

The provider callback will be called any time there is a choice of multiple AUR packages that can satisfy a dependency. This callback receives the dependency that we are trying to satisfy and a slice of package names satisfying it.

The callback returns returns the index of which package to pick.

Retuning an invalid index will cause a panic.

Source

#### pub fn group_callback<F: Fn(&[Group<'a>]) -> Vec<&'a Package> + 'static>( self, f: F, ) -> Self

Set the group callback

The group callback is called whenever a group is processed. The callback recieves the group and returns a list of packages should be installed from the group;

Source

#### pub fn is_devel<F: Fn(&str) -> bool + 'static>(self, f: F) -> Self

Set the function for determining if a package is devel.

Devel packages are never skipped when using NEEDED.

By default, no packages are considered devel.

Source§

### impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>

Source

#### pub fn new( alpm: &'a Alpm, cache: &'b mut Cache, raur: &'b H, flags: Flags, ) -> Self

Create a new Resolver

Source

#### pub fn aur_namespace(self, enable: bool) -> Self

If enabled, causes `aur/foo` to mean from the AUR, instead of a repo named `aur`.

Source

#### pub fn custom_aur_namespace(self, name: Option<String>) -> Self

Causes `<name>/foo` to mean from the AUR, instead of a repo named `<name>`.

Source

#### pub fn pkgbuild_repos(self, repos: Vec<PkgbuildRepo<'a>>) -> Self

Set the pkgbuild repos to use.

Source

#### pub fn get_cache(&self) -> &Cache

Getter for the aur cache

Source

#### pub fn get_cache_mut(&mut self) -> &mut Cache

Mut getter for the aur cache

Source

#### pub async fn resolve_targets<T: AsTarg>( self, pkgs: &[T], ) -> Result<Actions<'a>, Error>

Resolve a list of targets.

Source

#### pub async fn resolve_depends<T: AsRef<str>>( self, deps: &[T], make_deps: &[T], ) -> Result<Actions<'a>, Error>

Resolve a list of dependencies.

Source

#### fn where_is_target(&self, targ: Targ<'_>) -> RepoSource

Source

#### fn split_targets<'t, T: AsTarg>( &mut self, deps: &'t [T], make_deps: &'t [T], is_target: bool, ) -> Targets<'t, 'a>

Source

#### async fn resolve<T: AsTarg>( self, deps: &[T], make_deps: &[T], is_target: bool, ) -> Result<Actions<'a>, Error>

Source

#### fn resolve_aur_target( &mut self, aur_pkg: &str, make: &HashSet<&str>, is_target: bool, targs: &[&str], ) -> Result<(), Error>

Source

#### fn resolve_repo_target( &mut self, pkg: Targ<'_>, alpm_pkg: &'a Package, make: &HashSet<&str>, is_target: bool, )

Source

#### fn resolve_pkgbuild_target( &mut self, pkgbuild: Targ<'_>, make: &HashSet<&str>, is_target: bool, targs: &[&str], ) -> Result<(), Error>

Source

#### fn find_satisfier_aur_cache(&self, dep: &Dep) -> Option<&ArcPackage>

Source

#### fn select_satisfier_aur_cache( &self, dep: &Dep, target: bool, ) -> Option<&ArcPackage>

Expected behaviour pull in a list of all matches, if one is installed, default to it. unless we are looking for a target, then always show all options.

Source

#### fn resolve_aur_pkg_deps( &mut self, targs: &[&str], pkg: AurOrPkgbuild<'_>, make: bool, ) -> Result<(), Error>

Source

#### fn find_pkgbuild_repo_dep( &self, repo_targ: Option<&str>, dep: &Depend, ) -> Option<(&str, &Srcinfo, &Package)>

Source

#### fn should_skip_aur_pkg(&self, dep: &Depend, is_target: bool) -> bool

Source

#### fn resolve_repo_pkg(&mut self, pkg: &'a Package, target: bool, make: bool)

Source

#### async fn cache_aur_pkgs<S: AsRef<str>>( &mut self, pkgs: &[S], target: bool, ) -> Result<Vec<ArcPackage>, Error>

Source

#### async fn cache_provides<S: AsRef<str>>( &mut self, pkgs: &[S], ) -> Result<Vec<ArcPackage>, Error>

Source

#### async fn cache_aur_pkgs_recursive<S: AsRef<str>>( &mut self, pkgs: &[S], pkgbuilds: &[Targ<'_>], target: bool, ) -> Result<(), Error>

Source

#### fn find_aur_deps_of_pkgbuild(&mut self, targ: Targ<'_>) -> Vec<String>

Source

#### async fn cache_aur_pkgs_recursive2<S: AsRef<str>>( &mut self, pkgs: &[S], pkgbuild_pkgs: &[Targ<'_>], target: bool, ) -> Result<Vec<String>, Error>

Source

#### fn satisfied_build(&self, target: &Dep) -> bool

Source

#### fn satisfied_install(&self, target: &Dep) -> bool

Source

#### fn satisfied_local(&self, target: &Dep) -> bool

Source

#### fn find_repo_target_satisfier(&self, target: Targ<'_>) -> Option<&'a Package>

Source

#### fn find_repo_satisfier<S: AsRef<str>>(&self, target: S) -> Option<&'a Package>

Source

#### fn find_repo_satisfier_silent<S: AsRef<str>>( &self, target: S, ) -> Option<&'a Package>

Source

#### fn dep_is_aur_targ(&self, targs: &[&str], dep: &Dep) -> bool

Source

#### fn pkgbuild_dep_in_base( &self, dep: &str, base: &Srcinfo, arch: &str, check_depends: bool, ) -> bool

Source

#### fn push_aur_build(&mut self, pkgbase: &str, pkg: AurPackage)

Source

#### fn push_pkgbuild_build(&mut self, repo: String, base: Srcinfo, pkg: Pkgbuild)

Source

#### pub(crate) fn find_pkgbuild( &self, name: &str, ) -> Option<(&'a str, &'a Srcinfo, &'a Package)>

Source

#### pub(crate) fn is_pkgbuild(&self, name: &str) -> bool

Source

#### fn calculate_make(&mut self)

Source

#### fn assume_installed(&self, dep: &Dep) -> bool

Source

#### fn arch(&self) -> &str

Source§

### impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>

Source

#### fn update_targs<'c>( alpm: &'c Alpm, local: Option<AlpmList<'_, &'c Db>>, ) -> Vec<&'c Package>

Source

#### pub async fn updates( &mut self, local: Option<&[&str]>, ) -> Result<Updates<'a>, Error>

Get aur packages need to be updated.

##### §Example

    use std::collections::HashSet;
    use alpm::Alpm;
    use raur::Handle;

    use aur_depends::{Flags, Resolver};

    let alpm = Alpm::new("/", "/var/lib/pacman")?;
    let raur = Handle::default();
    let mut cache = HashSet::new();
    let mut resolver = Resolver::new(&alpm, Vec::new(), &mut cache, &raur, Flags::aur_only());

    let updates = resolver.updates().await?;

    for update in updates.aur_updates {
        println!("update: {}: {} -> {}", update.local.name(), update.local.version(),
        update.remote.version);
    }

## Trait Implementations§

Source§

### impl<'a, 'b, H: Debug> Debug for Resolver<'a, 'b, H>

Source§

#### fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

## Auto Trait Implementations§

§

### impl<'a, 'b, H> Freeze for Resolver<'a, 'b, H>

§

### impl<'a, 'b, H = Handle> !RefUnwindSafe for Resolver<'a, 'b, H>

§

### impl<'a, 'b, H = Handle> !Send for Resolver<'a, 'b, H>

§

### impl<'a, 'b, H = Handle> !Sync for Resolver<'a, 'b, H>

§

### impl<'a, 'b, H> Unpin for Resolver<'a, 'b, H>

§

### impl<'a, 'b, H = Handle> !UnwindSafe for Resolver<'a, 'b, H>

## 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.

§

### impl<T> Instrument for T

§

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

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

#### 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> IntoEither for T

Source§

#### fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left` is `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. Read more
Source§

#### fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. 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.
§

### impl<T> WithSubscriber for T

§

#### 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
§

#### fn with_current_subscriber(self) -> WithDispatch<Self>

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