array_object/
lib.rs

1//! # ArrayObject
2//! A simple self-describing array of integers, real numbers, complex numbers and strings, designed for object storage, database and single file.
3//!
4//! Examples
5//! --------
6//! Encoding and decording:
7//! ```
8//! use array_object::*;
9//!
10//! fn main() {
11//!     // Convert data into binary
12//!     let original = vec![1u32, 2, 3, 4];
13//!     let obj: ArrayObject = original.clone().try_into().unwrap();
14//!     let packed = obj.pack(); // This converts the data into Vec<u8>.
15//!
16//!     // Restore data
17//!     let unpacked = ArrayObject::unpack(packed).unwrap();
18//!     let inflated: Vec<u32> = unpacked.try_into().unwrap();
19//!     assert_eq!(original, inflated);
20//! }
21//! ```
22//!
23//! One can also use the macros to write and read a file:
24//! ```
25//! use array_object::*;
26//!
27//! fn main() {
28//!     // Save into a file
29//!     let original = vec![1f64, 2.2, -1.1, 5.6];
30//!     export_obj!("testdata.bin", original.clone()); // The type has to be known at this point.
31//!
32//!     // Load from a file
33//!     let restored: Vec<f64> = import_obj!("testdata.bin"); // The type annotation is required.
34//!     assert_eq!(original, restored);
35//! }
36//! ```
37
38/// Adaptors for Complex and Array. These can be used to restore the data or construct ArrayObject without num::complex, ndarray or nalgebra.
39pub mod adaptor;
40mod bitfield;
41mod convert;
42mod error;
43mod external;
44mod misc;
45mod pack;
46mod storage;
47
48pub use misc::TryConcat;
49pub use pack::Pack;
50pub use pack::Unpack;
51pub use storage::{ArrayObject, DataType};