Skip to main content

Module engine

Module engine 

Source
Expand description

Spreadsheet engine API.

This module provides the core computation engine for the spreadsheet:

Structs§

AST
Compiled AST (abstract syntax tree) of a Rhai script.
Cell
A cell in the spreadsheet grid.
CellRef
A reference to a cell by row and column indices (0-indexed).
Dynamic
Dynamic type containing any value.

Enums§

CellType
The type of content stored in a cell.
ShiftOperation
Operation for shifting cell references in formulas.

Functions§

create_engine
Create a Rhai engine with built-ins registered.
create_engine_with_functions
Create a Rhai engine with built-ins registered. Optionally compiles custom functions from the provided script. Returns the engine, compiled AST (if any), and any error message.
create_engine_with_functions_and_spill
Create a Rhai engine with built-ins, custom functions, and shared maps. Returns the engine, compiled AST (if any), and any error message.
create_engine_with_spill
Create a Rhai engine with built-ins registered and shared maps.
detect_cycle
Detect circular dependencies starting from a cell. Returns Some(cycle_path) if a cycle is found, None otherwise.
eval_with_functions
Evaluate a formula, optionally with custom functions AST.
extract_dependencies
Extract all cell references from a script as dependencies.
format_dynamic
Format a Dynamic value for display.
format_number
Format a number for display.
parse_range
Parse a cell range like “A1:B5” and return (start_row, start_col, end_row, end_col).
preprocess_script
Replace cell references like “A1” with Rhai function calls like “cell(0, 0)”. Typed refs like “@A1” become “value(0, 0)” (returns Dynamic). Also transforms range functions like SUM(A1:B5, …) into sum_range(0, 0, 4, 1, …).
preprocess_script_with_context
Preprocess script with optional current cell context for ROW()/COL(). When context is provided, ROW() and COL() are replaced with 1-based row/col values.
shift_formula_references
Shift cell references in a formula when rows/cols are inserted/deleted. Returns the updated formula string.

Type Aliases§

ComputedMap
Thread-safe storage for computed formula cell values. Maps cell positions to their evaluated Dynamic values. This allows cell references to use pre-computed values instead of re-evaluating.
Grid
Thread-safe sparse grid storage.
SpillMap
Thread-safe storage for spill cell values. Maps cell positions to their computed Dynamic values.