Skip to main content

Module expression

Module expression 

Source
Expand description

Typed expression engine for data-driven style evaluation.

Expression<T> is the core type used by the style system to represent values that may depend on zoom level, feature properties, feature state, or combinations thereof.

§Design

Rather than interpreting JSON expression arrays at runtime (the MapLibre approach, motivated by JavaScript’s lack of a type system), Rustial uses a typed enum AST that is:

  • Compile-time checked — invalid expressions cannot be constructed.
  • Zero-cost for constantsExpression::Constant(v) is a plain value.
  • Branch-predictor friendly — evaluation is a single match dispatch.
  • Rust-ergonomic — users build expressions with constructors, not JSON.

JSON-based style documents (MapLibre/Mapbox .json) are parsed into Expression<T> by the style-json feature’s deserialiser, making JSON an input format rather than the core representation.

§Backward compatibility

[StyleValue<T>] is a type alias for Expression<T>, preserving all existing API call-sites.

Structs§

ExprEvalContext
Full evaluation context for expressions.

Enums§

BoolExpression
A boolean expression that evaluates to bool.
Expression
A typed expression that evaluates to a value of type T.
NumericExpression
A numeric expression that evaluates to f64.
StringExpression
A string expression that evaluates to a String.

Type Aliases§

FeatureProperties
Properties of a single feature being styled.