pub struct State<DP: DependencyProvider> {
pub root_package: Id<DP::P>,
pub incompatibilities: Map<Id<DP::P>, Vec<IncompId<<DP as DependencyProvider>::P, <DP as DependencyProvider>::VS, <DP as DependencyProvider>::M>>>,
pub partial_solution: PartialSolution<DP>,
pub incompatibility_store: Arena<Incompatibility<DP::P, DP::VS, DP::M>>,
pub package_store: HashArena<DP::P>,
/* private fields */
}Expand description
Current state of the PubGrub algorithm.
Fields§
§root_package: Id<DP::P>The root package and version.
incompatibilities: Map<Id<DP::P>, Vec<IncompId<<DP as DependencyProvider>::P, <DP as DependencyProvider>::VS, <DP as DependencyProvider>::M>>>All incompatibilities indexed by package.
partial_solution: PartialSolution<DP>Partial solution.
incompatibility_store: Arena<Incompatibility<DP::P, DP::VS, DP::M>>The store is the reference storage for all incompatibilities.
package_store: HashArena<DP::P>The store is the reference storage for all packages.
Implementations§
Source§impl<DP: DependencyProvider> State<DP>
impl<DP: DependencyProvider> State<DP>
Sourcepub fn add_package_version_dependencies(
&mut self,
package: Id<DP::P>,
version: DP::V,
dependencies: impl IntoIterator<Item = (DP::P, DP::VS)>,
) -> Option<IncompId<DP::P, DP::VS, DP::M>>
pub fn add_package_version_dependencies( &mut self, package: Id<DP::P>, version: DP::V, dependencies: impl IntoIterator<Item = (DP::P, DP::VS)>, ) -> Option<IncompId<DP::P, DP::VS, DP::M>>
Add the dependencies for the current version of the current package as incompatibilities.
Sourcepub fn add_incompatibility(
&mut self,
incompat: Incompatibility<DP::P, DP::VS, DP::M>,
)
pub fn add_incompatibility( &mut self, incompat: Incompatibility<DP::P, DP::VS, DP::M>, )
Add an incompatibility to the state.
Sourcepub fn add_proxy_package(
&mut self,
proxy_package: Id<DP::P>,
base_package: Id<DP::P>,
versions: DP::VS,
)
pub fn add_proxy_package( &mut self, proxy_package: Id<DP::P>, base_package: Id<DP::P>, versions: DP::VS, )
Add a single custom incompatibility that requires the base package and the proxy package share the same version range.
This intended for cases where proxy packages (also known as virtual packages) are used. Without this information, pubgrub does not know that these packages have to be at the same version. In cases where the base package is already to an incompatible version, this avoids going through all versions of the proxy package. In cases where there are two incompatible proxy packages, it avoids trying versions for both of them. Both improve performance (we don’t need to check all versions when there is a conflict) and error messages (report a conflict of version ranges instead of enumerating the conflicting versions).
Using this method requires that each version of the proxy package depends on the exact version of the base package.
Sourcepub fn unit_propagation(
&mut self,
package: Id<DP::P>,
) -> Result<SmallVec<(Id<DP::P>, IncompId<<DP as DependencyProvider>::P, <DP as DependencyProvider>::VS, <DP as DependencyProvider>::M>)>, NoSolutionError<DP>>
pub fn unit_propagation( &mut self, package: Id<DP::P>, ) -> Result<SmallVec<(Id<DP::P>, IncompId<<DP as DependencyProvider>::P, <DP as DependencyProvider>::VS, <DP as DependencyProvider>::M>)>, NoSolutionError<DP>>
Unit propagation is the core mechanism of the solving algorithm. CF https://github.com/dart-lang/pub/blob/master/doc/solver.md#unit-propagation
For each package with a satisfied incompatibility, returns the package and the root cause incompatibility.
Sourcepub fn backtrack_package(&mut self, package: Id<DP::P>) -> Option<u32>
pub fn backtrack_package(&mut self, package: Id<DP::P>) -> Option<u32>
Manually backtrack before the given package was selected.
This can be used to switch the order of packages if the previous prioritization was bad.
Returns the number of the decisions that were backtracked, or None if the package was not
decided on yet.