Operators Reference

DataLogic-rs provides a comprehensive set of operators for building powerful expressions. These operators are organized into categories based on their functionality.

calculate

Arithmetic Operators

Arithmetic operators perform mathematical operations on numeric values.

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • % Modulo
  • max Maximum
  • min Minimum
  • abs Absolute value
  • ceil Ceiling (round up)
  • floor Floor (round down)
compare_arrows

Comparison Operators

Compare values: ==, ===, !=, !==, >, >=, <, <=

  • == Equal
  • === Strict Equal
  • != Not Equal
  • !== Strict Not Equal
  • > Greater Than
  • < Less Than
  • >= Greater Than or Equal
  • <= Less Than or Equal
view_array

Array Operators

Manipulate arrays: map, filter, reduce, some, all, merge

  • map Transform each item
  • filter Select matching items
  • reduce Accumulate values
  • all/some/none Check if items match
  • merge Combine arrays
  • in Check if value exists in array
  • length Get array or string length
  • slice Extract array or string portion
  • sort Sort array with options
text_format

String Operators

Manipulate strings: cat, substr, in, trim, length

  • cat Concatenate strings
  • substr Extract substring
  • starts_with Check if string starts with
  • ends_with Check if string ends with
  • upper Convert to uppercase
  • lower Convert to lowercase
  • trim Remove whitespace
tune

Variable Operators

Access data: var, missing, missing_some

  • var Access variables from data
  • missing Check for missing fields
  • missing_some Check if some required fields exist
  • valAccess values from data
  • exists Check if a value exists
build

Utility Operators

Type operations, error handling, and coalescing

  • type Get type of a value
  • try Try an operation with fallback
  • throw Throw an error
  • ?? Nullish coalescing operator
account_tree

Control Flow Operators

Control logic: if, and, or, !, ??

  • if Conditional execution
  • and Logical AND
  • or Logical OR
  • ! Logical NOT
  • ?? Null coalescing
schedule

Date & Time Operators

Work with dates and times: datetime, timestamp, now, parse_date, format_date, date_diff

  • datetime Convert string to datetime
  • timestamp Parse duration values
  • now Current timestamp
  • parse_date Parse string with format
  • format_date Format datetime with pattern
  • date_diff Calculate difference between dates

Custom Operators

DataLogic-rs allows you to extend the engine with custom operators through two different approaches:

CustomSimple and CustomAdvanced

CustomSimple - A simplified API for scalar operations with direct access to the data context
CustomAdvanced - Complete control via the CustomOperator trait with arena allocation

Custom operators enable you to create reusable, domain-specific logic that can be composed with built-in operators. Both approaches support seamless integration with DataLogic's rule evaluation system and provide access to the current data context.

Learn More About Custom Operators