pub enum Constraint {
Integer(IntConstraint),
Double(DoubleConstraint),
Boolean(BoolConstraint),
String(StringConstraint),
Selection(SelectionConstraint),
}Expand description
Kind-tagged constraint for dispatch against a Value.
Variants§
Integer(IntConstraint)
Constraint over an i64.
Double(DoubleConstraint)
Constraint over an f64.
Boolean(BoolConstraint)
Constraint over a bool.
String(StringConstraint)
Constraint over a String.
Selection(SelectionConstraint)
Constraint over a selection.
Implementations§
Source§impl Constraint
impl Constraint
Sourcepub fn test(&self, value: &Value) -> bool
pub fn test(&self, value: &Value) -> bool
Test a candidate value against this constraint. Kind-mismatched values always fail.
Sourcepub fn canonicalize(self) -> Self
pub fn canonicalize(self) -> Self
Canonicalise the contained per-kind constraint.
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
pub fn canonical_bytes(&self) -> Vec<u8> ⓘ
Canonical byte form. Delegates to the per-kind encoding — the first byte already identifies the kind because each kind uses a disjoint variant-tag range.
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Canonical fingerprint. Delegates to the per-kind fingerprint, which auto-canonicalises.
Trait Implementations§
Source§impl Clone for Constraint
impl Clone for Constraint
Source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Constraint
impl Debug for Constraint
Source§impl<'de> Deserialize<'de> for Constraint
impl<'de> Deserialize<'de> for Constraint
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Constraint
impl PartialEq for Constraint
Source§impl Serialize for Constraint
impl Serialize for Constraint
impl StructuralPartialEq for Constraint
Auto Trait Implementations§
impl Freeze for Constraint
impl RefUnwindSafe for Constraint
impl Send for Constraint
impl Sync for Constraint
impl Unpin for Constraint
impl UnsafeUnpin for Constraint
impl UnwindSafe for Constraint
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
Mutably borrows from an owned value. Read more