pub struct PackageResolver<'a> { /* private fields */ }Expand description
As implied by the name, this is the implementation of the dependency/package resolver.
The resolver is constructed for a specific root package, along with a reference to the current
state of the package index. Once constructed, you then ask the resolver for the dependencies
of the given package using PackageResolver::resolve. It is then up to the caller to take
those package and version selections and do something with them, typically fetching the actual
package content and using it for program execution or assembly of a new package.
Implementations§
Source§impl<'a> PackageResolver<'a>
Construction
impl<'a> PackageResolver<'a>
Construction
Sourcepub fn for_package_in_workspace(
package: &'a Package,
workspace: &'a Workspace,
index: &'a PackageIndex,
) -> Self
pub fn for_package_in_workspace( package: &'a Package, workspace: &'a Workspace, index: &'a PackageIndex, ) -> Self
Create a PackageResolver for package in workspace, using index.
It is assumed that the caller has already:
- Ensured that
indexhas been seeded withpackage, along with other members ofworkspace, and all versions of all packages known to the system that may be referenced as dependencies, directly or transitively. - Verified that
packageis a member ofworkspace. While resolution can still succeed if that isn’t the case, it may cause unexpected conflicts or selections to occur due to the special prioritization given to workspace members.
Sourcepub fn for_package(package: &'a Package, index: &'a PackageIndex) -> Self
pub fn for_package(package: &'a Package, index: &'a PackageIndex) -> Self
Create a PackageResolver for package, using index.
For packages that are members of a workspace, you should prefer
Self::for_package_in_workspace.
It is assumed that the caller has already:
- Ensured that
indexhas been seeded withpackage, along with all versions of all packages known to the system that may be referenced as dependencies, directly or transitively.
Source§impl<'a> PackageResolver<'a>
Dependency resolution
impl<'a> PackageResolver<'a>
Dependency resolution
pub fn resolve( self, ) -> Result<SelectedDependencies<Self>, DependencyResolutionError>
Sourcepub fn resolve_for(
&self,
package: impl Into<PackageId>,
version: SemVer,
) -> Result<SelectedDependencies<Self>, DependencyResolutionError>
pub fn resolve_for( &self, package: impl Into<PackageId>, version: SemVer, ) -> Result<SelectedDependencies<Self>, DependencyResolutionError>
Resolve dependencies for package with the given version.
If successful, this returns a map of PackageId to Version for all dependencies required
by package, transitively.
If unsuccesssful, a DependencyResolutionError is returned that indicates why it failed.
Trait Implementations§
Source§impl<'a> DependencyProvider for PackageResolver<'a>
This provides the version selection/dependency resolution functionality for PackageIndex via
pubgrub.
impl<'a> DependencyProvider for PackageResolver<'a>
This provides the version selection/dependency resolution functionality for PackageIndex via
pubgrub.
We provide a custom implementation, as our versioning scheme must handle a mix of requirements including both semantic versioning schemes as well as requirements on a specific package digest.
Source§type VS = VersionSet
type VS = VersionSet
The type used to represent version requirements.
NOTE: Requirements must be able to process versions of type V
Source§type M = String
type M = String
The error type used to communicate our own version selection issues, e.g.:
- The version would require building the package, but builds are disabled.
- The package is not available in the cache, but internet access has been disabled.
- The package uses a legacy format not supported anymore.
Currently we’re using String here as a placeholder until we determine a more appropriate
error type.
Source§type Priority = PackagePriority
type Priority = PackagePriority
The type used to represent prioritize package versions during selection.
Source§type Err = Infallible
type Err = Infallible
The error type returned from all functions of this trait that return errors.
Returning this signals that resolution should fail with this error.
We’re using Infallible here currently, as we don’t produce any errors that need to be
returned yet, this is likely to change in the near future.
Source§fn prioritize(
&self,
package: &Self::P,
range: &Self::VS,
_package_conflicts_counts: &PackageResolutionStatistics,
) -> Self::Priority
fn prioritize( &self, package: &Self::P, range: &Self::VS, _package_conflicts_counts: &PackageResolutionStatistics, ) -> Self::Priority
Source§fn choose_version(
&self,
package: &Self::P,
range: &Self::VS,
) -> Result<Option<Self::V>, Self::Err>
fn choose_version( &self, package: &Self::P, range: &Self::VS, ) -> Result<Option<Self::V>, Self::Err>
Priority package from all potential valid
packages, it needs to know what version of that package to use. The most common pattern
is to select the largest version that the range contains.Source§fn get_dependencies(
&self,
package: &Self::P,
version: &Self::V,
) -> Result<Dependencies<Self::P, Self::VS, Self::M>, Self::Err>
fn get_dependencies( &self, package: &Self::P, version: &Self::V, ) -> Result<Dependencies<Self::P, Self::VS, Self::M>, Self::Err>
Source§fn should_cancel(&self) -> Result<(), Self::Err>
fn should_cancel(&self) -> Result<(), Self::Err>
Auto Trait Implementations§
impl<'a> Freeze for PackageResolver<'a>
impl<'a> RefUnwindSafe for PackageResolver<'a>
impl<'a> Send for PackageResolver<'a>
impl<'a> Sync for PackageResolver<'a>
impl<'a> Unpin for PackageResolver<'a>
impl<'a> UnsafeUnpin for PackageResolver<'a>
impl<'a> UnwindSafe for PackageResolver<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more