Struct aur_depends::Resolver
source · [−]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
sourceimpl<'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 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<Package<'a>> + 'static>(
self,
f: F
) -> Self
pub fn group_callback<F: Fn(&[Group<'a>]) -> Vec<Package<'a>> + '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;
sourcepub fn devel_pkgs<F: Fn(&str) -> bool + 'static>(self, f: F) -> Self
pub fn devel_pkgs<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.
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 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 aur_updates(&mut self) -> Result<AurUpdates<'a>, Error>
pub async fn aur_updates(&mut self) -> Result<AurUpdates<'a>, Error>
Get which 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.aur_updates().await?;
for update in updates.updates {
println!("update: {}: {} -> {}", update.local.name(), update.local.version(),
update.remote.version);
}
sourcepub async fn local_aur_updates<S: AsRef<str>>(
&mut self,
repos: &[S]
) -> Result<AurUpdates<'a>, Error>
pub async fn local_aur_updates<S: AsRef<str>>(
&mut self,
repos: &[S]
) -> Result<AurUpdates<'a>, Error>
Fetch updates from a list of local repos.
Trait Implementations
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more