Skip to main content

ConditionalGuard

Enum ConditionalGuard 

Source
pub enum ConditionalGuard {
Show 17 variants Truthy { path: String, }, With { path: String, }, Eq { path: String, value: GuardValue, }, NotEq { path: String, value: GuardValue, }, Absent { path: String, }, TypeIs { path: String, schema_type: String, }, MatchesPattern { path: String, pattern: String, }, IntGt { path: String, bound: i64, }, IntLt { path: String, bound: i64, }, HasKey { path: String, key: String, }, ContainsMemberEquals { path: String, member: String, value: GuardValue, }, ContainsEquals { path: String, value: GuardValue, }, AtMostOneMember { path: String, }, MinMembers { path: String, bound: i64, }, Not(Box<ConditionalGuard>), AllOf(Vec<ConditionalGuard>), AnyOf(Vec<ConditionalGuard>),
}
Expand description

Values-decidable guard expression that can be lowered into JSON Schema conditionals.

Variants§

§

Truthy

The value at path is Helm-truthy.

Fields

§path: String

Values path tested for truthiness.

§

With

A with action selected the non-empty value at path.

Fields

§path: String

Values path selected by the action.

§

Eq

The value at path equals a literal.

Fields

§path: String

Values path compared with the literal.

§value: GuardValue

Literal required at the path.

§

NotEq

The value at path differs from a literal.

Fields

§path: String

Values path compared with the literal.

§value: GuardValue

Literal excluded at the path.

§

Absent

The value at path is absent.

Fields

§path: String

Values path whose absence selects the branch.

§

TypeIs

The value at path has a specific JSON Schema type.

Fields

§path: String

Values path subjected to the type test.

§schema_type: String

JSON Schema type name accepted by the branch.

§

MatchesPattern

The string at path matches a regular expression.

Fields

§path: String

Values path subjected to the pattern test.

§pattern: String

ECMA-compatible regular expression required by the branch.

§

IntGt

The path’s RAW value is a JSON integer strictly greater than bound — a sound SUBSET of the Sprig coercion (gt (int64 x) bound) it stands in for, valid only where firing less often is safe.

Fields

§path: String

Values path subjected to the integer comparison.

§bound: i64

Exclusive lower bound.

§

IntLt

The mirror of ConditionalGuard::IntGt: the path’s RAW value is a JSON integer strictly less than bound, under the same sound-subset contract.

Fields

§path: String

Values path subjected to the integer comparison.

§bound: i64

Exclusive upper bound.

§

HasKey

The mapping at path contains the literal member key. The key is an OPAQUE property name (it may contain dots), so it rides beside the segmented path instead of being appended to it.

Fields

§path: String

Values path expected to hold a mapping.

§key: String

Literal mapping key whose presence selects the branch.

§

ContainsMemberEquals

SOME iterated item of the collection at path has member equal to value — the document-level meaning of a range-sentinel flag (Range(path) ∧ Eq(path.*.member, value)). Lowers to contains over the array lane and the double-negated member quantifier over the object lane.

Fields

§path: String

Values path expected to hold the iterated collection.

§member: String

Member name compared within each collection item.

§value: GuardValue

Literal that at least one member must equal.

§

ContainsEquals

SOME item of the list at path deep-equals the scalar literal — Sprig has LITERAL .Values.list. has returns false on a nil haystack and aborts on non-lists, so the guard holds exactly for arrays carrying the literal; lowers to contains with a const item.

Fields

§path: String

Values path expected to hold the list.

§value: GuardValue

Literal that at least one list item must equal.

§

AtMostOneMember

The collection at path has at most one entry — the document-level form of “every iteration of this range is the first” (an empty-initialized dedup accumulator cannot have shadowed anything). A sound subset: it may only scope positive-polarity evidence.

Fields

§path: String

Values path expected to hold the bounded collection.

§

MinMembers

The value at path is a mapping with at least bound members (gt (keys X | len) N). Exact: both polarities encode.

Fields

§path: String

Values path expected to hold the mapping.

§bound: i64

Inclusive minimum number of members.

§

Not(Box<ConditionalGuard>)

Logical negation of a guard.

§

AllOf(Vec<ConditionalGuard>)

Conjunction of every enclosed guard.

§

AnyOf(Vec<ConditionalGuard>)

Disjunction of the enclosed guards.

Implementations§

Source§

impl ConditionalGuard

Source

pub fn value_paths(&self) -> BTreeSet<String>

Returns every values path referenced by this guard tree.

Source

pub fn map_value_paths<F>(self, map: &mut F) -> Self
where F: FnMut(&str) -> String,

Rewrite the values paths carried by this guard (and every nested guard).

Trait Implementations§

Source§

impl Clone for ConditionalGuard

Source§

fn clone(&self) -> ConditionalGuard

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 ConditionalGuard

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for ConditionalGuard

Source§

impl Hash for ConditionalGuard

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ConditionalGuard

Source§

fn cmp(&self, other: &ConditionalGuard) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ConditionalGuard

Source§

fn eq(&self, other: &ConditionalGuard) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for ConditionalGuard

Source§

fn partial_cmp(&self, other: &ConditionalGuard) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for ConditionalGuard

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<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.