Formualizer Docs
Reference

Rust API Map

Detailed overview of the Rust crates and core types in the Formualizer workspace.

Formualizer is organized as a modular Rust workspace, allowing users to depend only on the components they need.

Crate Overview

CrateResponsibility
formualizer-parseTokenization, parser, and AST construction.
formualizer-evalFormula evaluation engine, built-in functions, and recalc planning.
formualizer-commonShared types: LiteralValue, ExcelError, RangeAddress.
formualizer-workbookWorkbook state management, sheet orchestration, and evaluation.
formualizer-sheetportSheetPort runtime: sessions, batch execution, and typed I/O.
sheetport-specFIO manifest parsing, validation, and JSON Schema generation.
formualizer-macrosProcedural macros for internal crate optimizations.

Feature Flags

  • wasm_plugins: Enables loading custom functions via WebAssembly modules.
  • wasm_runtime_wasmtime: Uses Wasmtime as the backend for WASM plugins.
  • umya_integration: Provides helpers for integrating with the umya-spreadsheet crate.
  • serde: Enables Serde serialization/deserialization for core types.

Key Types and Methods

Core Values: LiteralValue

The LiteralValue enum represents any value that can exist in a cell or as an intermediate result.

  • Int(i64) / Number(f64)
  • Text(String)
  • Boolean(bool)
  • Array(Vec<Vec<LiteralValue>>)
  • Date(NaiveDate) / DateTime(NaiveDateTime) / Time(NaiveTime)
  • Duration(Duration)
  • Empty / Pending
  • Error(ExcelError)

Error Handling: ExcelErrorKind

Used within ExcelError to categorize calculation failures.

  • Null, Ref, Name, Value, Div, Na, Num, Error, NImpl, Spill, Calc, Circ, Cancelled

Workbook Management

The Workbook type in formualizer-workbook is the central coordinator.

  • add_sheet(name): Create a new sheet.
  • set_value(address, value): Update a cell with a literal.
  • set_formula(address, formula): Update a cell with a formula string.
  • evaluate(address): Trigger evaluation for a specific cell and its dependencies.

Interruptible Recalculation

formualizer_eval::engine exports EvaluationStop, EvaluationProgress, RecalcJobOptions, RecalcJobError, RecalcOutcome, StepReport, StepPhase, StepProgress, StepDelta, SlowUnitKind and SlowUnitReport.

  • evaluate_all_until(stop): implicit continuation returning Complete or Incomplete.
  • begin_recalc(options), step_recalc(stop), prioritize_recalc(targets): explicit job control returning typed job errors.
  • recalc_with(options, stop_per_step, on_step): callback driver returning Finished, Cancelled or Paused; the callback receives mutable Engine or Workbook access.
  • cancel_recalc(), has_active_recalc_job(): lifecycle control.
  • has_pending_in_rect(...), pending_cells_in_rect(...): zero-based inclusive viewport queries.

Workbook exposes the same methods; explicit job methods return RecalcJobError directly. Existing evaluation methods retain their error types, with ExcelErrorExtra::RecalcJobActive identifying a refused request. See Interruptible Recalculation.

SheetPort Runtime

SheetPort and SheetPortSession in formualizer-sheetport provide structured I/O.

  • SheetPortSession::new(workbook, manifest): Bind a manifest to a workbook the session owns; SheetPort::new(&mut workbook, manifest) borrows it instead.
  • session.write_inputs(update): Validate and write an InputUpdate (InputUpdate::from_iter([("rate", LiteralValue::Number(0.05))])).
  • session.evaluate_once(options) / session.read_outputs(): Recalculate and read the output ports.
  • sheetport_spec::Manifest::new(id).port(Port::input(id, location, schema)): Build a manifest in code; Manifest::from_yaml_str and to_yaml convert to and from YAML.

See Also

On this page