pub enum IntConstraint {
Always,
Never,
Min {
n: i64,
},
Max {
n: i64,
},
Range {
min: i64,
max: i64,
},
InSet {
values: BTreeSet<i64>,
},
NotInSet {
values: BTreeSet<i64>,
},
Multiple {
n: i64,
},
And {
children: Vec<Self>,
},
Or {
children: Vec<Self>,
},
Not {
child: Box<Self>,
},
}Expand description
Integer-value constraint.
Variants track SRD-0004 §Constraint algebra. Multiple(0) is a legal
representation but always tests false; the constructor Self::multiple
rejects zero so callers that go through the helper never produce it.
Variants§
Always
Always satisfied.
Never
Never satisfied.
Min
value >= n.
Max
value <= n.
Range
min <= value <= max.
InSet
value is one of these.
NotInSet
value is none of these.
Multiple
value % n == 0. Always false for n == 0.
And
All children must hold.
Or
At least one child must hold.
Not
Child must not hold.
Implementations§
Source§impl IntConstraint
impl IntConstraint
Sourcepub fn canonicalize(self) -> Self
pub fn canonicalize(self) -> Self
Collapse identities, peel double negation, flatten same-kind
combinators, sort And/Or children by canonical bytes, and
dedup.
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
pub fn canonical_bytes(&self) -> Vec<u8> ⓘ
Canonical byte form of this constraint as written.
Two constraints with the same canonical bytes are structurally
identical. Self::fingerprint canonicalises first and is
what you want for semantic identity.
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Canonical fingerprint — semantically identical constraints hash to the same value. Auto-canonicalises the tree before hashing.
Trait Implementations§
Source§impl Clone for IntConstraint
impl Clone for IntConstraint
Source§fn clone(&self) -> IntConstraint
fn clone(&self) -> IntConstraint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IntConstraint
impl Debug for IntConstraint
Source§impl<'de> Deserialize<'de> for IntConstraint
impl<'de> Deserialize<'de> for IntConstraint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for IntConstraint
impl Hash for IntConstraint
Source§impl Not for IntConstraint
impl Not for IntConstraint
Source§impl PartialEq for IntConstraint
impl PartialEq for IntConstraint
Source§impl Serialize for IntConstraint
impl Serialize for IntConstraint
impl Eq for IntConstraint
impl StructuralPartialEq for IntConstraint
Auto Trait Implementations§
impl Freeze for IntConstraint
impl RefUnwindSafe for IntConstraint
impl Send for IntConstraint
impl Sync for IntConstraint
impl Unpin for IntConstraint
impl UnsafeUnpin for IntConstraint
impl UnwindSafe for IntConstraint
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.