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>
impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>
Sourcepub fn provider_callback<F: Fn(&str, &[&str]) -> usize + 'static>(
self,
f: F,
) -> Self
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.
Sourcepub fn group_callback<F: Fn(&[Group<'a>]) -> Vec<&'a Package> + 'static>(
self,
f: F,
) -> Self
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§impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>
impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>
Sourcepub fn new(
alpm: &'a Alpm,
cache: &'b mut Cache,
raur: &'b H,
flags: Flags,
) -> Self
pub fn new( alpm: &'a Alpm, cache: &'b mut Cache, raur: &'b H, flags: Flags, ) -> Self
Create a new Resolver
Sourcepub fn aur_namespace(self, enable: bool) -> Self
pub fn aur_namespace(self, enable: bool) -> Self
If enabled, causes aur/foo to mean from the AUR, instead of a repo named aur.
Sourcepub fn custom_aur_namespace(self, name: Option<String>) -> Self
pub fn custom_aur_namespace(self, name: Option<String>) -> Self
Causes <name>/foo to mean from the AUR, instead of a repo named <name>.
Sourcepub fn pkgbuild_repos(self, repos: Vec<PkgbuildRepo<'a>>) -> Self
pub fn pkgbuild_repos(self, repos: Vec<PkgbuildRepo<'a>>) -> Self
Set the pkgbuild repos to use.
Sourcepub fn get_cache_mut(&mut self) -> &mut Cache
pub fn get_cache_mut(&mut self) -> &mut Cache
Mut getter for the aur cache
Sourcepub async fn resolve_targets<T: AsTarg>(
self,
pkgs: &[T],
) -> Result<Actions<'a>, Error>
pub async fn resolve_targets<T: AsTarg>( self, pkgs: &[T], ) -> Result<Actions<'a>, Error>
Resolve a list of targets.
Sourcepub async fn resolve_depends<T: AsRef<str>>(
self,
deps: &[T],
make_deps: &[T],
) -> Result<Actions<'a>, Error>
pub async fn resolve_depends<T: AsRef<str>>( self, deps: &[T], make_deps: &[T], ) -> Result<Actions<'a>, Error>
Resolve a list of dependencies.
fn where_is_target(&self, targ: Targ<'_>) -> RepoSource
fn split_targets<'t, T: AsTarg>( &mut self, deps: &'t [T], make_deps: &'t [T], is_target: bool, ) -> Targets<'t, 'a>
async fn resolve<T: AsTarg>( self, deps: &[T], make_deps: &[T], is_target: bool, ) -> Result<Actions<'a>, Error>
fn resolve_aur_target( &mut self, aur_pkg: &str, make: &HashSet<&str>, is_target: bool, targs: &[&str], ) -> Result<(), Error>
fn resolve_repo_target( &mut self, pkg: Targ<'_>, alpm_pkg: &'a Package, make: &HashSet<&str>, is_target: bool, )
fn resolve_pkgbuild_target( &mut self, pkgbuild: Targ<'_>, make: &HashSet<&str>, is_target: bool, targs: &[&str], ) -> Result<(), Error>
fn find_satisfier_aur_cache(&self, dep: &Dep) -> Option<&ArcPackage>
Sourcefn select_satisfier_aur_cache(
&self,
dep: &Dep,
target: bool,
) -> Option<&ArcPackage>
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.
fn resolve_aur_pkg_deps( &mut self, targs: &[&str], pkg: AurOrPkgbuild<'_>, make: bool, ) -> Result<(), Error>
fn find_pkgbuild_repo_dep( &self, repo_targ: Option<&str>, dep: &Depend, ) -> Option<(&str, &Srcinfo, &Package)>
fn should_skip_aur_pkg(&self, dep: &Depend, is_target: bool) -> bool
fn resolve_repo_pkg(&mut self, pkg: &'a Package, target: bool, make: bool)
async fn cache_aur_pkgs<S: AsRef<str>>( &mut self, pkgs: &[S], target: bool, ) -> Result<Vec<ArcPackage>, Error>
async fn cache_provides<S: AsRef<str>>( &mut self, pkgs: &[S], ) -> Result<Vec<ArcPackage>, Error>
async fn cache_aur_pkgs_recursive<S: AsRef<str>>( &mut self, pkgs: &[S], pkgbuilds: &[Targ<'_>], target: bool, ) -> Result<(), Error>
fn find_aur_deps_of_pkgbuild(&mut self, targ: Targ<'_>) -> Vec<String>
async fn cache_aur_pkgs_recursive2<S: AsRef<str>>( &mut self, pkgs: &[S], pkgbuild_pkgs: &[Targ<'_>], target: bool, ) -> Result<Vec<String>, Error>
fn satisfied_build(&self, target: &Dep) -> bool
fn satisfied_install(&self, target: &Dep) -> bool
fn satisfied_local(&self, target: &Dep) -> bool
fn find_repo_target_satisfier(&self, target: Targ<'_>) -> Option<&'a Package>
fn find_repo_satisfier<S: AsRef<str>>(&self, target: S) -> Option<&'a Package>
fn find_repo_satisfier_silent<S: AsRef<str>>( &self, target: S, ) -> Option<&'a Package>
fn dep_is_aur_targ(&self, targs: &[&str], dep: &Dep) -> bool
fn pkgbuild_dep_in_base( &self, dep: &str, base: &Srcinfo, arch: &str, check_depends: bool, ) -> bool
fn push_aur_build(&mut self, pkgbase: &str, pkg: AurPackage)
fn push_pkgbuild_build(&mut self, repo: String, base: Srcinfo, pkg: Pkgbuild)
pub(crate) fn find_pkgbuild( &self, name: &str, ) -> Option<(&'a str, &'a Srcinfo, &'a Package)>
pub(crate) fn is_pkgbuild(&self, name: &str) -> bool
fn calculate_make(&mut self)
fn assume_installed(&self, dep: &Dep) -> bool
fn arch(&self) -> &str
Source§impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>
impl<'a, 'b, E: Error + Sync + Send + 'static, H: Raur<Err = E> + Sync> Resolver<'a, 'b, H>
fn update_targs<'c>( alpm: &'c Alpm, local: Option<AlpmList<'_, &'c Db>>, ) -> Vec<&'c Package>
Sourcepub async fn updates(
&mut self,
local: Option<&[&str]>,
) -> Result<Updates<'a>, Error>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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