Expand description
BEVE - Binary Efficient Versatile Encoding
High-performance, tagged binary format designed for scientific computing. This crate provides a robust, fast, and ergonomic implementation with serde support.
- Little-endian encoding
- Direct struct serialization via
serde::{Serialize, Deserialize} - Typed arrays for numeric, boolean, and string sequences when possible
- Object keys as strings or integer types
- Enum variants as ordinary values, per BEVE Version 2 (what
serde_jsonwrites) - Zero-copy deserialization for
&strfields (borrow directly from the input buffer) - Validation helpers for checking BEVE payload integrity without deserialization
- Selective field loading via JSON Pointer (RFC 6901)
with optional array slicing — see
from_fieldandfrom_field_slice
Example
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct Point { x: f64, y: f64 }
let p = Point { x: 1.0, y: -2.0 };
let bytes = beve::to_vec(&p).unwrap();
let p2: Point = beve::from_slice(&bytes).unwrap();
assert_eq!(p, p2);Validate a payload without decoding it into a concrete Rust type:
use std::io::Cursor;
let bytes = beve::to_vec(&vec![1u32, 2, 3]).unwrap();
beve::validate_slice(&bytes).unwrap();
beve::validate_reader(Cursor::new(bytes)).unwrap();Re-exports§
pub use crate::aligned::aligned_typed_slice_size;pub use crate::aligned::read_aligned_typed_slice;pub use crate::aligned::read_aligned_typed_slice_ref;pub use crate::aligned::to_vec_aligned_typed_slice;pub use crate::aligned::write_aligned_typed_slice;pub use crate::aligned::write_aligned_typed_slice_at;pub use crate::fast::BeveTypedSlice;pub use crate::fast::complex_slice_size;pub use crate::fast::read_complex_slice;pub use crate::fast::read_complex_slice_from_reader;pub use crate::fast::read_typed_slice;pub use crate::fast::read_typed_slice_from_reader;pub use crate::fast::to_vec_bool_slice;pub use crate::fast::to_vec_complex_slice;pub use crate::fast::to_vec_str_slice;pub use crate::fast::to_vec_string_slice;pub use crate::fast::to_vec_typed_slice;pub use crate::fast::to_writer_complex_slice;pub use crate::fast::to_writer_typed_slice;pub use crate::fast::typed_slice_size;pub use crate::fast::write_bool_slice;pub use crate::fast::write_complex_slice;pub use crate::fast::write_str_slice;pub use crate::fast::write_string_slice;pub use crate::fast::write_typed_slice;pub use crate::field::from_field;pub use crate::field::from_field_slice;pub use crate::field::skip_value;pub use crate::mat::Compression;matpub use crate::mat::InvalidNamePolicy;matpub use crate::mat::LibVer;matpub use crate::mat::MatV73Options;matpub use crate::mat::NullPolicy;matpub use crate::mat::OneDimensionalMode;matpub use crate::mat::RootBinding;matpub use crate::mat::RowMajorPolicy;matpub use crate::mat::UnsupportedPolicy;matpub use crate::mat::beve_file_to_mat_v73_file;matpub use crate::mat::beve_slice_to_mat_v73_bytes;matpub use crate::mat::beve_slice_to_mat_v73_file;matpub use crate::mat::beve_slice_to_mat_v73_writer;mat
Modules§
- aligned
- Aligned typed numeric arrays — the BEVE wire type built for zero-copy access.
- complex
- Serde
serialize_withhelpers for foreign complex types (e.g.num_complex::Complex) that implementComplexElement(two contiguousComponentfields: re then im). - complex_
array #[serde(with = ...)]helpers for bulk (memcpy) decode of numeric (beve::typed::*) and complex (beve::complex_array::*) array fields.#[serde(with = "beve::complex_array::<scalar>")]for aVec<T>field whoseTis aComplexElementof that scalar: bulk encode and bulk (memcpy) decode of a complex array.- fast
- field
- Navigate into a BEVE payload using a JSON Pointer (RFC 6901) and deserialize only the targeted value. Intermediate values are skipped without allocation, making this efficient for extracting a single field from a large payload.
- mat
mat - BEVE -> MATLAB v7.3 conversion.
- typed
#[serde(with = ...)]helpers for bulk (memcpy) decode of numeric (beve::typed::*) and complex (beve::complex_array::*) array fields.#[serde(with = "beve::typed::<scalar>")]for aVec<scalar>field: bulk encode and bulk (memcpy) decode of a typed numeric array.- util
- BEVE-specific utilities and helper types.
Structs§
- Complex
- Complex
Slice - A contiguous slice of complex values, serialized as a BEVE complex array
with a single bulk write of the borrowed payload — the complex counterpart
of
TypedSlice. - Deserializer
- Matrix
- Matrix
Owned - RawMatrix
- Serializer
- Streaming
Deserializer - A BEVE deserializer that reads directly from a
std::io::Read. - Streaming
Serializer - A BEVE serializer that writes directly to a
std::io::Writewith zero buffering. - Typed
Slice - An opt-in wrapper that serializes a contiguous numeric slice
&[T]as a BEVE typed array via a single bulk write, rather than element-by-element.
Enums§
- BigInt
- Large integer that doesn’t fit in 64 bits.
- BigInt
Key - Large integer key that doesn’t fit in 64 bits.
- Decoded
Matrix - Error
- Marked
#[non_exhaustive]so that naming a new failure mode is not itself a breaking change: addingRecursionLimitExceededbroke every downstream exhaustivematch, and a decoder will keep learning to refuse things. - Key
- A map key that can be a string or integer.
- Matrix
Decode Mode - Matrix
Layout - Number
- A BEVE number, which can be signed, unsigned, or floating-point.
- Value
- Represents any valid BEVE value.
- Value
Error - Error type for Value deserialization.
Constants§
- DATA_
DELIMITER - The single-byte data delimiter (BEVE extension 0).
- MAX_
RECURSION_ DEPTH - Ceiling on how deeply a decoded value may nest.
Traits§
- Complex
Element - A type the bulk complex-array helpers may read as raw bytes: two contiguous
Self::Componentscalars, real part first.
Functions§
- beve_
slice_ to_ json - Convert BEVE bytes into compact JSON bytes.
- beve_
slice_ to_ json_ string - Convert BEVE bytes into a JSON string.
- decode_
matrix_ slice - from_
reader - Deserialize a value by reading all bytes from a reader into a buffer first.
- from_
reader_ streaming - Deserialize a value by streaming from a reader without buffering the entire input.
- from_
slice - Deserialize a value from a BEVE byte slice.
- from_
value - Deserialize a concrete type from a
Value. - from_
value_ ref - Deserialize a concrete type from a
Valuereference. - json_
slice_ to_ beve - Convert JSON bytes into BEVE bytes without building an intermediate DOM.
- json_
str_ to_ beve - Convert a JSON string into BEVE bytes without building an intermediate DOM.
- serialized_
size - Compute the exact number of bytes
to_writer_streamingwould write forvalue, without producing them. - to_vec
- to_
vec_ into - to_
writer - Serialize a value into any writer.
- to_
writer_ streaming - Serialize directly to a writer with zero internal buffering.
- validate_
reader - Validate BEVE data from any reader without deserializing into a concrete type.
- validate_
slice - Validate that
bytescontains exactly one well-formed BEVE value. - write_
delimiter - Write a data delimiter byte to the given writer.