Skip to main content

Constraint

Enum Constraint 

Source
pub enum Constraint {
    Dependency {
        package: String,
        version_set: VersionSet,
        dependent: Option<String>,
    },
    Conflict {
        package1: String,
        version1: Version,
        package2: String,
        version2: Version,
    },
    AtMostOne {
        package: String,
        versions: Vec<Version>,
    },
    AtLeastOne {
        package: String,
        versions: Vec<Version>,
    },
    Exactly {
        package: String,
        version: Version,
    },
    Exclude {
        package: String,
        version: Version,
    },
    Implies {
        premise_package: String,
        premise_version: Version,
        conclusion_package: String,
        conclusion_version_set: VersionSet,
    },
    OptionalDependency {
        package: String,
        version_set: VersionSet,
        dependent: Option<String>,
        condition: Option<String>,
    },
    ConditionalDependency {
        package: String,
        version_set: VersionSet,
        dependent: Option<String>,
        condition: String,
    },
}
Expand description

A statement the SAT encoder must enforce.

All variants are hard constraints (must hold in any solution) unless explicitly described otherwise. Soft preferences (e.g. “prefer newer versions”) are expressed via assumptions on the solver, not via Constraint variants.

Variants§

§

Dependency

dependent (if present) depends on package in a version satisfying version_set. If dependent is None, this is a top-level / root dependency.

Fields

§package: String
§version_set: VersionSet
§dependent: Option<String>
§

Conflict

package1@version1 and package2@version2 may not both be selected. Two-clause exclusion.

Fields

§package1: String
§version1: Version
§package2: String
§version2: Version
§

AtMostOne

At most one of the listed versions of package may be selected. The standard “one version per package” rule for most ecosystems.

Fields

§package: String
§versions: Vec<Version>
§

AtLeastOne

At least one of the listed versions of package must be selected. Used when a dependency edge has multiple satisfying versions and we want the solver to pick some version.

Fields

§package: String
§versions: Vec<Version>
§

Exactly

Exactly this version of package must be selected. Used for pinning (e.g. lockfile-frozen installs).

Fields

§package: String
§version: Version
§

Exclude

This specific (package, version) pair must not be selected. Used for security advisories and explicit denies.

Fields

§package: String
§version: Version
§

Implies

If premise_package@premise_version is selected, then conclusion_package must be selected with a version satisfying conclusion_version_set. The base shape of a dependency edge in CNF.

Fields

§premise_package: String
§premise_version: Version
§conclusion_package: String
§conclusion_version_set: VersionSet
§

OptionalDependency

Like Self::Dependency but marked as not-required: the solver should satisfy it if it can, and skip it without error if it can’t.

Fields

§package: String
§version_set: VersionSet
§dependent: Option<String>
§condition: Option<String>

Platform-specific condition (e.g., “os=linux”, “arch=x64”). Interpretation is up to the caller; the SAT encoder treats it as opaque metadata.

§

ConditionalDependency

Like Self::Dependency but only active when condition is true. Caller is responsible for evaluating condition and either including or omitting this constraint accordingly; the SAT encoder treats it as a regular dependency when present.

Fields

§package: String
§version_set: VersionSet
§dependent: Option<String>
§condition: String

Implementations§

Source§

impl Constraint

Source

pub fn dependency( package: String, version_set: VersionSet, dependent: Option<String>, ) -> Self

Create a dependency constraint.

Source

pub fn optional_dependency( package: String, version_set: VersionSet, dependent: Option<String>, condition: Option<String>, ) -> Self

Create an optional-dependency constraint.

Source

pub fn conditional_dependency( package: String, version_set: VersionSet, dependent: Option<String>, condition: String, ) -> Self

Create a conditional-dependency constraint.

Source

pub fn primary_package(&self) -> Option<&str>

Return the primary package name this constraint references, if there is one canonical answer. For variants with multiple packages (conflicts, workspaces), returns the “subject” package per the variant’s docs.

Source

pub fn is_optional(&self) -> bool

True if this constraint is a soft preference rather than a hard requirement (i.e. it’s allowed to be unsatisfied without flagging UNSAT).

Source

pub fn is_conditional(&self) -> bool

True if this constraint’s activation depends on a caller-evaluated condition.

Trait Implementations§

Source§

impl Clone for Constraint

Source§

fn clone(&self) -> Constraint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Constraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<Reference, Outer, OuterFieldType, Inner> HasPart<Nested<Outer, Inner>> for Reference
where Reference: HasPart<Outer> + ?Sized, Outer: Part<PartType = Field<OuterFieldType>>, Inner: Part, OuterFieldType: HasPart<Inner, RawTarget = OuterFieldType> + PartialRefTarget + ?Sized,

Source§

unsafe fn part_ptr( ptr: *const <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::Ptr

Given a constant pointer to a target, produce a constant pointer to a part of it. Read more
Source§

unsafe fn part_ptr_mut( ptr: *mut <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::PtrMut

Given a mutable pointer to a target, produce a mutable pointer to a part of it. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more