Skip to main content

bicmath_core/
lib.rs

1//! BicMath core: the shared numerical contract.
2//!
3//! This crate owns:
4//! - [`number`]: exact integers, rationals, decimals, and explicit `f64`.
5//! - [`value`]: the recursive wire value model (quantities, money, matrices).
6//! - [`error`]: stable error codes and structured errors.
7//! - [`limits`]: resource limits and cooperative cancellation.
8//! - [`context`]: execution and numeric contexts.
9//! - [`schema`]: typed parameter/output schemas and validation.
10//! - [`contract`]: module and function descriptors, the [`contract::Function`] trait.
11//! - [`envelope`]: the versioned result envelope.
12//! - [`fingerprint`]: canonical encoding, fingerprints, and replay receipts.
13//! - [`expr`]: the restricted expression grammar and parser (no function resolution).
14//!
15//! No transport, async runtime, filesystem, clock, or network code lives here.
16
17pub mod context;
18pub mod contract;
19pub mod envelope;
20pub mod error;
21pub mod eval;
22pub mod expr;
23pub mod fingerprint;
24pub mod limits;
25pub mod number;
26pub mod schema;
27pub mod value;
28
29pub use context::{Budget, EffectiveContext, ExecContext, TraceLevel};
30pub use contract::{
31    Args, Assumption, CostClass, Determinism, ErrorEstimate, Example, ExampleExpectation, Function,
32    FunctionDescriptor, FunctionRef, Module, ModuleDescriptor, Outcome, ParamDescriptor, Purity,
33    Trace, TraceStep, Warning,
34};
35pub use envelope::{EngineInfo, ErrorResponse, Exactness, ResultEnvelope};
36pub use error::{EngineError, ErrorCode};
37pub use eval::{FloatCalls, NumberCalls, SimpleCalls, evaluate_f64, evaluate_number};
38pub use expr::{Expr, parse_expression};
39pub use fingerprint::{Receipt, canonical_json_bytes, fingerprint_json};
40pub use limits::{CancellationToken, Limits, LimitsOverride};
41pub use number::NumericContext;
42pub use number::{Decimal, Float64, Number, NumberResult, NumericMode, RoundingMode};
43pub use schema::{FieldSchema, ValueSchema};
44pub use value::{Bound, Dimension, Value};
45
46/// Version of the public wire schema produced by this engine.
47pub const WIRE_SCHEMA_VERSION: u32 = 1;
48
49/// Version of the numerical policy semantics (rounding defaults, promotion rules,
50/// quantile conventions). Bump this whenever a semantic change could alter a
51/// downstream financial or statistical result, even if Rust types are unchanged.
52pub const NUMERICAL_POLICY_VERSION: u32 = 1;
53
54/// Crate version, as compiled.
55pub const VERSION: &str = env!("CARGO_PKG_VERSION");