bintext/
lib.rs

1//! Binary text encoding and decoding with support for SIMD (AVX2 and
2//! SSSE3) with good fallback performance.
3//!
4//! The main idea of this crate is to have a zero copy binary deserialization
5//! for text formats.
6//!
7//! ### How it works
8//!
9//! Alignment can't be guaranteed in a text format, so no matter what the data will need
10//! to be re-aligned while decoding, if the required alignment is `N` maximum amount
11//! of offset need to move the bytes is less than `N` thus by providing an start padding
12//! in the binary encoded text of `N - 1` it's possible to align the data up to `N`.
13//!
14//! **Quick note** this crate will only accept padding equal or grater than `N`, because
15//! it's a bit cheap to do this way.
16//!
17//! ```rust
18//! // Padding of 8 (suppose it was read form a file)
19//! let mut hex = "--------a1f7d5e8d14f0f76".to_string();
20//!
21//! unsafe {
22//!     // Decode with padding of 8 and alignment of 8
23//!     let slice = bintext::hex::decode_aligned(&mut hex, 8, 8).unwrap();
24//!     // Data is aligned so you can safely do this:
25//!     let slice: &[u64] = std::slice::from_raw_parts(
26//!        slice.as_ptr() as *const _,
27//!        slice.len() / std::mem::size_of::<u64>()
28//!     );
29//! }
30//! ```
31
32pub mod hex;