Crate tbon[−][src]
Library for encoding Rust program data into a binary stream, and decoding that stream.
Example:
let expected = ("one".to_string(), 2.0, vec![3, 4], Bytes::from(vec![5u8])); let stream = tbon::en::encode(&expected).unwrap(); let actual = block_on(tbon::de::try_decode((), stream)).unwrap(); assert_eq!(expected, actual);
Important note: TBON adds one byte to primitive values to record the value’s type. In cases
where TBON must encode a large number of values of the same type, such as an n-dimensional array
of numbers, this adds 12-50% overhead to the size of the encoded data. However, encoding a
Bytes
struct has a negligible overhead of only two bytes, regardless of the data size.
To efficiently encode an n-dimensional array, it is recommended to use compression
(e.g. gzip) and/or implement destream::FromStream
and destream::ToStream
using Bytes
.
Modules
de | Decode a Rust data structure from a TBON-encoded stream. |
en | Encode a Rust data structure into a TBON stream. |