[][src]Trait pubgrub::solver::DependencyProvider

pub trait DependencyProvider<P: Package, V: Version> {
    pub fn choose_package_version<T: Borrow<P>, U: Borrow<Range<V>>>(
        &self,
        potential_packages: impl Iterator<Item = (T, U)>
    ) -> Result<(T, Option<V>), Box<dyn Error>>;
pub fn get_dependencies(
        &self,
        package: &P,
        version: &V
    ) -> Result<Dependencies<P, V>, Box<dyn Error>>; pub fn should_cancel(&self) -> Result<(), Box<dyn Error>> { ... } }

Trait that allows the algorithm to retrieve available packages and their dependencies. An implementor needs to be supplied to the resolve function.

Required methods

pub fn choose_package_version<T: Borrow<P>, U: Borrow<Range<V>>>(
    &self,
    potential_packages: impl Iterator<Item = (T, U)>
) -> Result<(T, Option<V>), Box<dyn Error>>

Decision making is the process of choosing the next package and version that will be appended to the partial solution. Every time such a decision must be made, potential valid packages and version ranges are preselected by the resolver, and the dependency provider must choose.

The strategy employed to choose such package and version cannot change the existence of a solution or not, but can drastically change the performances of the solver, or the properties of the solution. The documentation of Pub (PubGrub implementation for the dart programming language) states the following:

Pub chooses the latest matching version of the package with the fewest versions that match the outstanding constraint. This tends to find conflicts earlier if any exist, since these packages will run out of versions to try more quickly. But there's likely room for improvement in these heuristics.

A helper function choose_package_with_fewest_versions is provided to ease implementations of this method if you can produce an iterator of the available versions in preference order for any package.

Note: the type T ensures that this returns an item from the packages argument.

pub fn get_dependencies(
    &self,
    package: &P,
    version: &V
) -> Result<Dependencies<P, V>, Box<dyn Error>>

Retrieves the package dependencies. Return Dependencies::Unknown if its dependencies are unknown.

Loading content...

Provided methods

pub fn should_cancel(&self) -> Result<(), Box<dyn Error>>

This is called fairly regularly during the resolution, if it returns an Err then resolution will be terminated. This is helpful if you want to add some form of early termination like a timeout, or you want to add some form of user feedback if things are taking a while. If not provided the resolver will run as long as needed.

Loading content...

Implementors

impl<P: Package, V: Version> DependencyProvider<P, V> for OfflineDependencyProvider<P, V>[src]

An implementation of DependencyProvider that contains all dependency information available in memory. Packages are picked with the fewest versions contained in the constraints first. Versions are picked with the newest versions first.

Loading content...