State

Struct State 

Source
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>

Source

pub fn init(root_package: DP::P, root_version: DP::V) -> Self

Initialization of PubGrub state.

Source

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.

Source

pub fn add_incompatibility( &mut self, incompat: Incompatibility<DP::P, DP::VS, DP::M>, )

Add an incompatibility to the state.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<DP: Clone + DependencyProvider> Clone for State<DP>
where DP::P: Clone, DP::V: Clone, DP::VS: Clone, DP::M: Clone,

Source§

fn clone(&self) -> State<DP>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.