Skip to main content

Crate wolfram_expr

Crate wolfram_expr 

Source
Expand description

Efficient and ergonomic representation of Wolfram expressions in Rust.

Modules§

from_wxf
FromWXF — pull-based typed deserialization from a WxfReader.
symbol
Representation of Wolfram Language symbols.
to_wxf
ToWXF — per-Rust-type WXF encoder. Streams directly into a WxfWriter: compounds write a header then recurse into children. No intermediate Vec, no &dyn dispatch — fully monomorphized.
wxf
WXF wire-format enums, re-exported from wolfram_serialize, plus the ArrayElement impls that map Rust primitives to element-type tags.

Macros§

expr
Build a Wolfram Language Expr with WL-like syntax.

Structs§

ArrayBuf
Generic dense N-dimensional buffer parameterized by an element-type tag.
BigInteger
Wolfram Language BigInteger — arbitrary-precision integer carried as its textual decimal representation (e.g. "99999999999999999999999").
BigReal
Wolfram Language BigReal — arbitrary-precision real carried as its WL textual representation, including any precision/accuracy markers (e.g. "3.1415926535897932384650.“`).
Expr
Wolfram Language expression.
Normal
Wolfram Language “normal” expression: f[...].
RuleEntry
Single association entry — key, value, and a flag indicating Rule (->, immediate) vs RuleDelayed (:>, held).
Symbol
Wolfram Language symbol.

Enums§

CompressionLevel
zlib compression level passed to [to_wxf].
ExprKind
Wolfram Language expression variants.
ExpressionEnum
Top-level WXF expression token. #[repr(u8)] discriminants are the wire bytes.
HeaderEnum
WXF framing header bytes. No Display — header bytes overlap with some expression token bytes and are not used in error messages.
Number
Subset of ExprKind that covers number-type expression values.
NumericArrayEnum
WXF element-type tag for NumericArray. Discriminants are the WXF wire bytes.
PackedArrayEnum
WXF element-type tag for PackedArray. Same wire bytes as NumericArrayEnum but restricted to the packed-compatible variants (no unsigned integers).

Traits§

ArrayElement
Connects a Rust primitive to its element-type discriminant. Implemented once per (type, tag) pair: e.g. i32: ArrayElement<NumericArrayEnum> (with TAG = Integer32) and i32: ArrayElement<PackedArrayEnum> (with TAG = Integer32). Sealed — only the primitives in [sealed] above can satisfy the Sealed super-bound.
FromWXF
Deserialize a typed value by pulling tokens from a WxfReader.
NumericArrayRead
Common read API implemented by both the owned crate::NumericArray / crate::PackedArray and the runtime-handle NumericArray<T> in wolfram-library-link.
Reader
Raw byte source that lends buffer-lifetime views. 'de is the lifetime of the underlying buffer. Reads consume forward; there is no rewind, no peek.
ToWXF
Types that know how to serialize themselves into a WXF stream.

Functions§

from_wxf
Deserialize bytes (WXF; 8: or 8C: auto-detected) into a typed T.
from_wxf_ref
Deserialize bytes into a borrowed T whose &str / &[u8] fields point straight into bytes (zero-copy). The result borrows bytes, so the input must be uncompressed (8:) — a 8C: payload would have to be decompressed into a temporary the borrow couldn’t outlive (use [from_wxf] for the owned form, or read_wxf to borrow within a closure).
read_wxf
Read from a WXF blob (8: / 8C: auto-detected) via a WxfReader. The closure can pull one or more top-level values — e.g. a Function[List, …] wrapper around several arguments. For a single value, prefer [from_wxf].
to_wxf
Serialize value to WXF.

Type Aliases§

Association
Wolfram Language <|...|> — an ordered list of RuleEntry.
ByteArray
Owned byte buffer — Wolfram Language ByteArray["..."].
Complex32
Single 32-bit complex number — pair of f32 (real, imaginary). Layout matches the WXF ComplexReal32 element wire format. No _Complex float typedef exists in WolframLibrary.h, so this type is wolfram-expr-only.
Complex64
Single 64-bit complex number — pair of f64 (real, imaginary).
F32
32-bit floating-point real number. Not NaN.
F64
64-bit floating-point real number. Not NaN.
NumericArray
Portable, owned NumericArrayWL value.
PackedArray
Owned PackedArrayWL value.

Derive Macros§

Failure
Derive From<Enum> for Expr for an error enum: each variant becomes its Failure["VariantName", <|fields|>] expression (the expr! boilerplate one would otherwise write by hand, inferred from the enum).
FromWXF
Derive FromWXF for a struct or enum.
ToWXF
Derive ToWXF for a struct or enum.