Skip to content

v0.3.0

Latest
Compare
Choose a tag to compare
@konstin konstin released this 12 Feb 19:15
· 0 commits to dev since this release

PubGrub 0.3 has a more flexible interface and speeds resolution significantly. The public API is very different now, we
recommend starting the migration by implementing the new DependencyProvider interface following the
Guide.

All public interfaces are now in the root of the crate.

In the main interface, DependencyProvider, choose_package_version was split into two methods: prioritize
for choosing which package to decide next by assigning a priority to each package, and choose_version. The generic
parameters became associated types. The version set is configurable by an associated type.

Dependencies gained a generic parameter for custom incompatibility type outside version conflicts, such as packages
not available for the current platform or permission errors. This type is on DependencyProvider as
DependencyProvider::M.

pubgrub::range::Range now lives in its own crate as version_ranges::Ranges. A Version can be almost any
ordered type now, it only needs to support set operations through VersionSet.

At a glance, this is the new DependencyProvider interface:

pub trait DependencyProvider {
    type P: Package;
    type V: Debug + Display + Clone + Ord;
    type VS: VersionSet<V = Self::V>;
    type M: Eq + Clone + Debug + Display;
    type Priority: Ord + Clone;
    type Err: Error + 'static;

    fn prioritize(
        &self,
        package: &Self::P,
        range: &Self::VS,
        package_conflicts_counts: &PackageResolutionStatistics,
    ) -> Self::Priority;

    fn choose_version(
        &self,
        package: &Self::P,
        range: &Self::VS,
    ) -> Result<Option<Self::V>, Self::Err>;

    fn get_dependencies(
        &self,
        package: &Self::P,
        version: &Self::V,
    ) -> Result<Dependencies<Self::P, Self::VS, Self::M>, Self::Err>;

}