Struct RuleBuilder

Source
pub struct RuleBuilder<'a> { /* private fields */ }
Expand description

Main builder for creating JSONLogic rules.

This is the entry point for the builder API, providing access to different specialized builders for different types of operations.

Implementations§

Source§

impl<'a> RuleBuilder<'a>

Source

pub fn new(arena: &'a DataArena) -> Self

Creates a new rule builder.

Source

pub fn arena(&self) -> &'a DataArena

Returns the arena this builder uses.

Source

pub fn compare(&self) -> ComparisonBuilder<'a>

Creates a comparison builder.

Source

pub fn arithmetic(&self) -> ArithmeticBuilder<'a>

Creates an arithmetic builder.

Source

pub fn control(&self) -> ControlBuilder<'a>

Creates a control flow builder.

Source

pub fn array(&self) -> ArrayBuilder<'a>

Creates an array operation builder.

Source

pub fn string_ops(&self) -> StringBuilder<'a>

Creates a string operation builder.

Source

pub fn datetime(&self) -> DateTimeBuilder<'a>

Creates a datetime operation builder.

Source

pub fn var(&self, path: &str) -> VariableBuilder<'a>

Creates a variable reference.

Source

pub fn val_op<T: Into<DataValue<'a>>>(&self, path: T) -> Logic<'a>

Creates a val token with the given path components. The path can be a string, number, or array of components.

Source

pub fn val_str(&self, path: &str) -> Logic<'a>

Creates a val token with a string path.

Source

pub fn val_path<I, T>(&self, components: I) -> Logic<'a>
where I: IntoIterator<Item = T>, T: Into<DataValue<'a>>,

Creates a val token with an array of path components. Each component can be a string or number for array indices.

Source

pub fn value<T: Into<DataValue<'a>>>(&self, value: T) -> Logic<'a>

Creates a literal value.

Source

pub fn bool(&self, value: bool) -> Logic<'a>

Creates a literal boolean value.

Source

pub fn int(&self, value: i64) -> Logic<'a>

Creates a literal integer value.

Source

pub fn float(&self, value: f64) -> Logic<'a>

Creates a literal float value.

Source

pub fn string_value(&self, value: &str) -> Logic<'a>

Creates a literal string value.

Source

pub fn null(&self) -> Logic<'a>

Creates a literal null value.

Source

pub fn var_with_default(&self, path: &str, default: Logic<'a>) -> Logic<'a>

Creates a logic that gets a variable and returns a default if it doesn’t exist.

Source

pub fn missing_op<T: Into<Logic<'a>>>(&self, variables: T) -> Logic<'a>

Creates a missing check for the specified variables. Returns an array of variables that are missing from the data context.

Source

pub fn missing_var(&self, variable: &str) -> Logic<'a>

Creates a missing check for a single variable.

Source

pub fn missing_vars<I, S>(&self, variables: I) -> Logic<'a>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Creates a missing check for multiple variables.

Source

pub fn missing_some_op<T: Into<Logic<'a>>>( &self, min_required: i64, variables: T, ) -> Logic<'a>

Creates a missing_some check, which returns an array of variables that are missing from the data context if the number of present variables is less than the required number.

Source

pub fn throw_op<T: Into<Logic<'a>>>(&self, error: T) -> Logic<'a>

Creates a throw operator that throws an error with the given value.

Source

pub fn try_op<I, T>(&self, expressions: I) -> Logic<'a>
where I: IntoIterator<Item = T>, T: Into<Logic<'a>>,

Creates a try operator that attempts to evaluate a sequence of expressions. Returns the result of the first one that succeeds. If all expressions fail, the last error is propagated.

Source

pub fn type_op(&self) -> TypeBuilder<'a>

Create a type operator that returns the type of a value

Auto Trait Implementations§

§

impl<'a> Freeze for RuleBuilder<'a>

§

impl<'a> !RefUnwindSafe for RuleBuilder<'a>

§

impl<'a> !Send for RuleBuilder<'a>

§

impl<'a> !Sync for RuleBuilder<'a>

§

impl<'a> Unpin for RuleBuilder<'a>

§

impl<'a> !UnwindSafe for RuleBuilder<'a>

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