Expand description
Serialize and deserialize Wolfram Language expressions to and from the WXF binary wire format.
Two layers:
- Byte level —
Reader/Writer.Readerlends zero-copy buffer-lifetime views (&'de), so the defaultSliceReaderreads straight out of an in-memory buffer; the default writer isVec<u8>. - WXF level —
WxfReader/WxfWriter, typed sugar over the byte layer built on the WXF token enums.
Per-Rust-type encoding/decoding is ToWXF / FromWXF, both generic over
the byte layer (monomorphized, no dyn, streaming). Top-level entry points:
[to_wxf] (compression optional), [from_wxf], read_wxf.
Re-exports§
pub use crate::errors::Error;pub use crate::complex::Complex;pub use crate::complex::Complex32;pub use crate::complex::Complex64;pub use crate::constants::ExpressionEnum;pub use crate::constants::HeaderEnum;pub use crate::constants::NumericArrayEnum;pub use crate::constants::PackedArrayEnum;pub use crate::from_wxf::FromWXF;pub use crate::reader::Reader;pub use crate::reader::SliceReader;pub use crate::to_wxf::ToWXF;pub use crate::to_wxf::WxfStruct;pub use crate::writer::Writer;pub use crate::wxf::reader::WxfReader;pub use crate::wxf::writer::WxfWriter;
Modules§
- complex
- Complex number primitives suitable as element types of
NumericArrayand [PackedArray][crate::PackedArray]. - constants
- WXF wire-format constants and enums.
- errors
- The crate-wide WXF error type.
- from_
wxf FromWXF— pull-based typed deserialization from aWxfReader.- numeric_
in - Flexible numeric-input helpers — accept any of NumericArray, PackedArray,
or ByteArray on the wire and widen the element type into the caller’s
target
T. The widening rules are lossless: a source type is accepted only when every value of its domain is exactly representable in the target. - reader
- Minimal byte-level reader.
- strategy
- Encoding strategies — the conventions for mapping Rust shapes onto WXF
expressions. These sit a layer above the cursor (
WxfReader/WxfWriter, which only know raw WXF tokens) and are shared by the#[derive]codegen and the hand-written std impls (Option,Result, …) so the wire format lives in exactly one place. - to_wxf
ToWXF— per-Rust-type WXF encoder. Streams directly into aWxfWriter: compounds write a header then recurse into children. No intermediateVec, no&dyndispatch — fully monomorphized.- writer
- Minimal byte-level writer.
- wxf
- WXF binary wire format — typed
WxfReader/WxfWriter. Header framing (8:/8C:) is handled by [crate::wxf_payload].
Enums§
- Compression
Level - zlib compression level passed to [
to_wxf].
Functions§
- from_
wxf - Deserialize
bytes(WXF;8:or8C:auto-detected) into a typedT. - from_
wxf_ ref - Deserialize
bytesinto a borrowedTwhose&str/&[u8]fields point straight intobytes(zero-copy). The result borrowsbytes, so the input must be uncompressed (8:) — a8C:payload would have to be decompressed into a temporary the borrow couldn’t outlive (use [from_wxf] for the owned form, orread_wxfto borrow within a closure). - read_
wxf - Read from a WXF blob (
8:/8C:auto-detected) via aWxfReader. The closure can pull one or more top-level values — e.g. aFunction[List, …]wrapper around several arguments. For a single value, prefer [from_wxf]. - to_wxf
- Serialize
valueto WXF.