aur_depends

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

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§

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

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.

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, 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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T