10 releases
Uses new Rust 2024
| 0.3.0 | Jan 16, 2026 |
|---|---|
| 0.2.3 | Mar 25, 2025 |
| 0.2.2 | Dec 1, 2024 |
| 0.2.1 | Nov 9, 2024 |
| 0.1.4 | Oct 21, 2024 |
#319 in Debugging
Used in 4 crates
(2 directly)
110KB
2.5K
SLoC
Array Object
ArrayObject is a self-describing binary format for arrays of integers, floating-point numbers, complex numbers, and strings. It is designed for efficient object storage, database integration, and single-file use.
ArrayObject is part of the dbgbb project.
Features
- Self-describing data that can inflate into typed variables.
- Simple, uniform arrays: no nested structures, tuples, or dataset names.
- Generic integer and float types abstract away type size differences.
- Automatic compression via variable-length encoding and dictionary coding for strings, minimizing storage size.
- Seamless conversions to and from
Vec<_>,[T; N],ndarray, andnalgebra.
Usage Examples
Encoding and Decoding
use array_object::*;
fn main() {
// Convert data into binary
let original = vec![1u32, 2, 3, 4];
let obj: ArrayObject = original.clone().try_into().unwrap();
let packed = obj.pack(); // Converts data into Vec<u8>
// Restore data
let unpacked = ArrayObject::unpack(packed).unwrap();
let inflated: Vec<u32> = unpacked.try_into().unwrap();
assert_eq!(original, inflated);
}
File Operations with Macros
use array_object::*;
fn main() {
// Save to a file
let original = vec![1f64, 2.2, -1.1, 5.6];
export_obj!("testdata.bin", original.clone()); // Overwrites if file exists
// Load from a file
let restored: Vec<f64> = import_obj!("testdata.bin"); // Type annotation required
assert_eq!(original, restored);
}
Crate Features
| Feature | Description |
|---|---|
allow_float_down_convert |
Enables implicit conversion (e.g., f64 to f32). |
ndarray_15 |
Enables ndarray support for version 0.15.x. |
ndarray_16 |
Enables ndarray support for version 0.16.x. |
ndarray_17 |
Enables ndarray support for version 0.16.x. |
nalgebra_33 |
Enables nalgebra support for version 0.33.x. |
nalgebra_34 |
Enables nalgebra support for version 0.34.x. |
Dependencies
~0.2–1.3MB
~26K SLoC