pub enum StringConstraint {
Always,
Never,
Regex {
pattern: RegexPattern,
},
LengthRange {
min: u32,
max: u32,
},
NonEmpty,
InSet {
values: BTreeSet<String>,
},
NotInSet {
values: BTreeSet<String>,
},
And {
children: Vec<Self>,
},
Or {
children: Vec<Self>,
},
Not {
child: Box<Self>,
},
}Expand description
String-value constraint.
Variants§
Always
Always satisfied.
Never
Never satisfied.
Regex
Value must match this regex.
Fields
§
pattern: RegexPatternThe compiled pattern.
LengthRange
min <= value.len() <= max (byte length).
NonEmpty
!value.is_empty().
InSet
Value is in this set.
NotInSet
Value is not in this set.
And
All children must hold.
Or
At least one child must hold.
Not
Child must not hold.
Implementations§
Source§impl StringConstraint
impl StringConstraint
Sourcepub fn canonicalize(self) -> Self
pub fn canonicalize(self) -> Self
Same rule set as IntConstraint::canonicalize.
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
pub fn canonical_bytes(&self) -> Vec<u8> ⓘ
Canonical byte form of this constraint as written.
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Canonical fingerprint — auto-canonicalises first. Regex leaves hash their source pattern (not the compiled automaton).
Trait Implementations§
Source§impl Clone for StringConstraint
impl Clone for StringConstraint
Source§fn clone(&self) -> StringConstraint
fn clone(&self) -> StringConstraint
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 StringConstraint
impl Debug for StringConstraint
Source§impl<'de> Deserialize<'de> for StringConstraint
impl<'de> Deserialize<'de> for StringConstraint
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 Hash for StringConstraint
impl Hash for StringConstraint
Source§impl Not for StringConstraint
impl Not for StringConstraint
Source§impl PartialEq for StringConstraint
impl PartialEq for StringConstraint
Source§impl Serialize for StringConstraint
impl Serialize for StringConstraint
impl Eq for StringConstraint
impl StructuralPartialEq for StringConstraint
Auto Trait Implementations§
impl Freeze for StringConstraint
impl RefUnwindSafe for StringConstraint
impl Send for StringConstraint
impl Sync for StringConstraint
impl Unpin for StringConstraint
impl UnsafeUnpin for StringConstraint
impl UnwindSafe for StringConstraint
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
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
Compare self to
key and return true if they are equal.