This library used to serialize and deserialize structured data in binary format.
Examples
[]
= "0.3"
use ;
let old = Company ;
let bytes = old.;
let new = .unwrap;
Vec, String, &[T], &str etc.. are encoded with their length value first, Following by each entry.
By default, length of collections is represented with BEU30.
use ;
let bytes = ;
// ^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Id Len Data
let msg = .unwrap;
assert_eq!;
assert_eq!; // Here, data is referenced.
- Example: Encoding data into a buffer of specified size.
use ;
/// Use big endian byte order + Encode `msg` length with `databuf::var_int::BEU15`
const CONFIG: u8 = BE | BEU15;
let record = Record ;
let mut buf = ;
let remaining = &mut buf.as_mut_slice;
record..unwrap;
let amt = 20 - remaining.len;
assert_eq!; // 15 bytes written to `buf`