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
// Copyright (C) 2020 - 2022, J2 Innovations
//! Brio binary encoding/decoding for Haystack values.
//!
//! Brio is a compact binary format used by Project Haystack and the Haxall platform.
//! It provides efficient binary serialization of all Haystack value types.
//!
//! # Features
//! - `brio-encoding`: enables the [`encode`] module
//! - `brio-decoding`: enables the [`decode`] module
//!
//! # Example – round-trip a `Dict`
//! ```rust
//! use libhaystack::val::*;
//! use libhaystack::dict;
//! use libhaystack::encoding::brio::encode::ToBrio;
//! use libhaystack::encoding::brio::decode::from_brio;
//!
//! let val = Value::make_dict(dict! {
//! "site" => Value::make_marker(),
//! "dis" => Value::from("Main Campus")
//! });
//!
//! let bytes = val.to_brio_vec().expect("encode");
//! let decoded = from_brio(&mut bytes.as_slice()).expect("decode");
//! assert_eq!(val, decoded);
//! ```