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::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;
Modules§
- complex
- Complex number primitives suitable as element types of
NumericArrayandPackedArray. - constants
- WXF wire-format constants and enums.
- 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. - 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.
Structs§
- Slice
Reader - Slice-backed
Reader: holds&[u8]plus a position. Every read is a bounds-checked sub-slice — no allocation, no copy. - WxfReader
- Typed WXF reader wrapping a raw byte
Reader. - WxfWriter
- Typed WXF writer wrapping a raw byte
Writer.
Enums§
- Compression
Level - zlib compression level passed to
to_wxf. - Error
- Errors returned by
to_wxf/from_wxfand everyToWXF/FromWXFimpl.
Traits§
- Reader
- Raw byte source that lends buffer-lifetime views.
'deis 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.
- Writer
- Raw byte sink.
- WxfStruct
- Marker auto-implemented by
#[derive(ToWXF)]for user structs/enums. Gates the blanketimpl ToWXF for Vec<T>(List form) so it can’t conflict with the numeric-primitiveVecspecializations.
Functions§
- from_
wxf - Deserialize
bytes(WXF;8:or8C:auto-detected) into a typedT. - read_
wxf - Strip the WXF header (
8:/8C:auto-detected, decompressing if needed) and hand the closure aWxfReaderpositioned at the start of the token stream, so it can drive the cursor directly. - to_wxf
- Serialize
valueto WXF.