pub fn resolve<DP: DependencyProvider>(
dependency_provider: &DP,
package: DP::P,
version: impl Into<DP::V>,
) -> Result<SelectedDependencies<DP>, PubGrubError<DP>>Expand description
Finds a set of packages satisfying dependency bounds for a given package + version pair.
It consists in efficiently finding a set of packages and versions that satisfy all the constraints of a given project dependencies. In addition, when that is not possible, PubGrub tries to provide a very human-readable and clear explanation as to why that failed. Below is an example of explanation present in the introductory blog post about PubGrub (Although this crate is not yet capable of building formatting quite this nice.)
Because dropdown >=2.0.0 depends on icons >=2.0.0 and
root depends on icons <2.0.0, dropdown >=2.0.0 is forbidden.
And because menu >=1.1.0 depends on dropdown >=2.0.0,
menu >=1.1.0 is forbidden.
And because menu <1.1.0 depends on dropdown >=1.0.0 <2.0.0
which depends on intl <4.0.0, every version of menu
requires intl <4.0.0.
So, because root depends on both menu >=1.0.0 and intl >=5.0.0,
version solving failed.Is generic over an implementation of DependencyProvider which represents where the dependency constraints come from. The associated types on the DependencyProvider allow flexibility for the representation of package names, version requirements, version numbers, and other things. See its documentation for more details. For simple cases OfflineDependencyProvider may be sufficient.
ยงAPI
let solution = resolve(&dependency_provider, package, version)?;The call to resolve for a given package at a given version will compute the set of packages and versions needed to satisfy the dependencies of that package and version pair. If there is no solution, the reason will be provided as clear as possible.