pub struct Resolver<'a, 'b, H = Handle> { /* private fields */ }
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)
}
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
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 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);
}