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 support via BEVE type-tag extension
- 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;
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 are layout-compatible withbeve::Complex<T>(two contiguousTfields: 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 whereTis layout-compatible withComplex<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.
- 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 - Deserializer
- Matrix
- Matrix
Owned - RawMatrix
- Serializer
- Serializer
Options - 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 - Enum
Encoding - Error
- 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).
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. - serialized_
size_ with_ options - Compute the exact streaming-encoded byte length of
valueunder customSerializerOptions, without producing the bytes. - to_vec
- to_
vec_ into - to_
vec_ into_ with_ options - to_
vec_ with_ options - to_
writer - Serialize a value into any writer.
- to_
writer_ streaming - Serialize directly to a writer with zero internal buffering.
- to_
writer_ streaming_ with_ options - Serialize directly to a writer with zero internal buffering and custom options.
- to_
writer_ with_ options - Serialize a value into any writer with custom options.
- 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.