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.
Conflict
package1@version1 and package2@version2 may not both be
selected. Two-clause exclusion.
AtMostOne
At most one of the listed versions of package may be
selected. The standard “one version per package” rule for
most ecosystems.
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.
Exactly
Exactly this version of package must be selected.
Used for pinning (e.g. lockfile-frozen installs).
Exclude
This specific (package, version) pair must not be
selected. Used for security advisories and explicit denies.
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
conclusion_version_set: VersionSetOptionalDependency
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
version_set: VersionSetConditionalDependency
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.
Implementations§
Source§impl Constraint
impl Constraint
Sourcepub fn dependency(
package: String,
version_set: VersionSet,
dependent: Option<String>,
) -> Self
pub fn dependency( package: String, version_set: VersionSet, dependent: Option<String>, ) -> Self
Create a dependency constraint.
Sourcepub fn optional_dependency(
package: String,
version_set: VersionSet,
dependent: Option<String>,
condition: Option<String>,
) -> Self
pub fn optional_dependency( package: String, version_set: VersionSet, dependent: Option<String>, condition: Option<String>, ) -> Self
Create an optional-dependency constraint.
Sourcepub fn conditional_dependency(
package: String,
version_set: VersionSet,
dependent: Option<String>,
condition: String,
) -> Self
pub fn conditional_dependency( package: String, version_set: VersionSet, dependent: Option<String>, condition: String, ) -> Self
Create a conditional-dependency constraint.
Sourcepub fn primary_package(&self) -> Option<&str>
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.
Sourcepub fn is_optional(&self) -> bool
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).
Sourcepub fn is_conditional(&self) -> bool
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
impl Clone for Constraint
Source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more