Expand description
§ArrayObject
A simple self-describing array of integers, real numbers, complex numbers and strings, designed for object storage, database and single file.
§Examples
The simplest way to write and read a file is to use the macros.
use array_object::*;
fn main() {
// Save into a file
let original = vec![1f64, 2.2, -1.1, 5.6];
export_obj!("testdata.bin", original.clone()); // The type has to be known at this point.
// Load from a file
let restored: Vec<f64> = import_obj!("testdata.bin"); // The type annotation is required.
assert_eq!(original, restored);
}An example using ArrayObject explicitly is the following.
use array_object::*;
fn main() {
// Convert data into binary
let original = vec![1u32, 2, 3, 4];
let obj: ArrayObject = original.clone().into();
let packed = obj.pack(); // This converts the data into Vec<u8>.
// Restore data
let unpacked = ArrayObject::unpack(packed).unwrap();
let inflated: Vec<u32> = unpacked.try_into().unwrap();
assert_eq!(original, inflated);
}Modules§
- Adaptors for Complex and Array. These can be used to restore the data or construct ArrayObject without num::complex, ndarray or nalgebra.
Macros§
- A macro to save the data into a file.
- A macro to load the data from a file.
Structs§
- The main array storage.
Enums§
- The type of the array.
Traits§
- Convert into binary.
- Concat ArrayObjects of the same type, size and shape.
- Restore from binary.