Enum Predicate

Source
pub enum Predicate {
    FirstOrder(FirstOrder),
    SecondOrder(SecondOrder),
}
Expand description

A Predicate is an Object whose members describe a testable condition that evaluates as either true or false.

The essential components of a Predicate include:

  • A label identifying the predicate operation,
  • A reference to the value being tested, and
  • The condition against which the referenced value is to be evaluated.

Predicate objects MUST have exactly one “op” member whose value indicates the type of predicate operation to perform. It’s value MUST be one of: “and”, “contains”, “contains-”, “defined”, “ends”, “ends-”, “in”, “in-”, “less”, “matches”, “matches-”, “more”, “not”, “or”, “starts”, “starts-”, “test”, “test-”, “type”, or “undefined”.

The semantics for each are defined in the sections that follow.

Note that the value of the “op” member is case-sensitive and that each of the operations listed are in lower-case. The value “Starts”, for example, is not equivalent to “starts”.

If the “op” member specifies any value other than one of those listed above, the evaluation of the predicate operation MUST cease and be handled as if a boolean value of “false” was returned. The application processing the predicate operation MAY signal that an error condition has occurred depending on the specific requirements of the application within which JSON Predicates are being used.

The remaining structure of each predicate operation depends on the specific type. There are two basic types of predicates.

  • First Order Predicates that are used to test one name value pair against a single condition, and

  • Second Order Predicates that aggregate one or more subordinate First or Second Order Predicates.

In addition to the required “op” member, First Order Predicates have exactly one “path” member whose value MUST be a string containing a JSON-Pointer RFC6901 value referencing the name value pair that is to be tested. If the “path” member is not specified within the predicate object, it’s value is assumed to be an empty string.

Second Order Predicates MUST have exactly one “apply” member whose value is a JSON Array containing one or more First or Second Order Predicate Objects.

Additional members can be required depending on the specific predicate operation. All other members not explicitly defined by this specification MUST be ignored.

Note that the ordering of members in JSON objects is not significant; therefore the following operations are equivalent:

{"op": "contains", "path": "/a/b/c", "value": "ABC"}
{"path": "/a/b/c", "op": "contains", "value": "ABC"}
{"value": "ABC", "path": "/a/b/c", "op": "contains"}

Variants§

§

FirstOrder(FirstOrder)

§

SecondOrder(SecondOrder)

Trait Implementations§

Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Predicate

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Predicate

Source§

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

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

impl<'de> Deserialize<'de> for Predicate

Source§

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 From<FirstOrder> for Predicate

Source§

fn from(value: FirstOrder) -> Self

Converts to this type from the input type.
Source§

impl From<SecondOrder> for Predicate

Source§

fn from(value: SecondOrder) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Predicate

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PredicateImpl for Predicate

Source§

fn evaluate( &self, data: &Value, ctx: PredicateContext, ) -> Result<bool, PredicateError>

Evaluate the predicate against the provided JSON Read more
Source§

fn test(&self, data: &Value, ctx: PredicateContext) -> bool

Evaluate the predicate against the provided JSON
Source§

impl Serialize for Predicate

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Predicate

Source§

impl StructuralPartialEq for Predicate

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,