array_object/lib.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
//! # 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);
//! }
//! ```
/// Adaptors for Complex and Array. These can be used to restore the data or construct ArrayObject without num::complex, ndarray or nalgebra.
pub mod adaptor;
mod convert;
mod error;
mod external;
mod misc;
mod pack;
mod storage;
pub use misc::TryConcat;
pub use pack::Pack;
pub use pack::Unpack;
pub use storage::{ArrayObject, DataType};