rs_teststand/expression/mod.rs
1//! The engine's expression language.
2//!
3//! Expressions are how a sequence computes: preconditions, limits, and any
4//! value written into a step. This module models the language itself, what the
5//! operators are and how they bind, separately from the object model, so
6//! nothing about expressions is bolted onto `Engine` or `PropertyObject`.
7//!
8//! To *evaluate* an expression, use
9//! [`PropertyObject::evaluate_ex`](crate::PropertyObject::evaluate_ex), which
10//! runs it in the context of a property.
11//!
12//! # Why the type names repeat their module
13//!
14//! `ArithmeticOperator` lives in `expression::operator::arithmetic`, and
15//! `ColorConstant` in `expression::constant::color`. Clippy's
16//! `module_name_repetitions` objects to that. It is wrong here, and the
17//! reasoning is worth keeping so nobody re-opens it.
18//!
19//! The suffix carries the meaning. The module path is the redundant half. Users
20//! do not write `expression::operator::arithmetic::Arithmetic`; the crate root
21//! re-exports flat, so they write `rs_teststand::ArithmeticOperator`. Stripping
22//! the suffix to satisfy the lint collides: seven types would all be called
23//! `Function`, six `Operator`, and two `Constant`, including `Other` twice.
24//!
25//! The names also are not ours to choose freely. This crate is a twin of the
26//! engine's own API, and the reference groups expression elements exactly this
27//! way, into operators, functions and constants, with the same subcategories.
28//! Someone reading the official documentation and then reaching for the Rust
29//! type should find the name they already know. A rename that reads better to a
30//! Rust linter but no longer matches what the vendor calls the thing trades a
31//! cosmetic win for the confusion this crate exists to prevent.
32//!
33//! So the lint is allowed at the workspace level rather than silenced per item,
34//! and this note is the record of why.
35
36pub mod constant;
37pub mod function;
38pub mod operator;
39
40pub use constant::{ColorConstant, OtherConstant};
41pub use function::{
42 ArrayFunction, NumericFunction, OtherFunction, PropertyFunction, StringFunction,
43 SwitchingFunction, TimeFunction,
44};
45pub use operator::{
46 ArithmeticOperator, Arity, AssignmentOperator, BitwiseOperator, ComparisonOperator,
47 LogicalOperator, Operator, OperatorClass, OtherOperator,
48};