openformula-kernel 0.1.0

Deterministic typed calculation kernel for an OpenFormula 1.4 function-semantics subset
Documentation
  • Coverage
  • 100%
    41 out of 41 items documented0 out of 1 items with examples
  • Size
  • Source code size: 59.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 843.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Nagitch/openformula-kernel
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Nagitch

openformula-kernel

openformula-kernel is a deterministic, typed Rust calculation kernel shared by Tanu Markdown, TSQ1, and Kitu. It implements a deliberately bounded subset of the function semantics in OpenFormula 1.4. It is not a complete formula parser, workbook engine, or OpenFormula-conforming evaluator.

The crate owns scalar values, numeric policy, coercion, typed calculation errors, standard functions, an injectable evaluation context, and a registry that keeps standard and namespaced extension functions separate. Callers keep ownership of parsing, references, dependency graphs, persistence, and UI.

Supported standard functions

The initial 0.1.0 API provides SUM, MIN, MAX, AVERAGE, IF, ABS, ROUND, FLOOR, CEILING, and POWER. See docs/compatibility.md for the normative section of OpenFormula 1.4 and every intentional difference.

use openformula_kernel::{Argument, FunctionRegistry, PureContext, Value};

let registry = FunctionRegistry::standard();
let mut context = PureContext;
let result = registry.evaluate(
    "SUM",
    &[
        Argument::scalar(Value::from(2_i64)),
        Argument::scalar(Value::from(3_i64)),
    ],
    &mut context,
)?;
assert_eq!(result, Value::from(5_i64));
# Ok::<(), openformula_kernel::CalcError>(())

Use FunctionRegistry::evaluate_lazy for IF so the unselected branch is never evaluated. Extensions must use a namespace such as KITU.CLAMP; the crate includes extensions::register_kitu_examples as a dependency-light example.

Distribution and compatibility

  • Releases use semantic versioning. A behavior change that can alter persisted calculation results requires at least a minor version before 1.0.
  • Consumers pin the same Git revision until a crates.io publication policy is adopted. Release tags use vMAJOR.MINOR.PATCH.
  • The default std feature only adds std::error::Error; the calculation core works with --no-default-features and alloc, including WASM consumers.
  • The stable public Number wrapper hides the current binary64 representation so a later decimal implementation does not force callers to rewrite APIs.

Verification

cargo fmt --all --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
cargo check --no-default-features

See docs/numeric-policy.md for determinism and rounding guarantees and docs/migration.md for consumer adapter guidance.