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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! # Serialization format
//!
//! The primitive de/serializable type is [`OptDatum<Datum>`].
//!
//! The below pseudocode depicts its serialized representations.
//!
//! They all start with `datum_type`, which is encoded in `u8`.
//! In case we need to deprecate supported datum_types over time, this allows us
//! `(pow(2, 8) - count_of_active_datum_types)` deprecations, before rolling over to zero.
//!
//! Some `Datum` types have fixed body lengths; these lengths are not encoded.
//! For other `Datum` types, which have dynamic body lengths, these lengths are
//! encoded following `datum_type`.
//! The body length is encoded before the body, so that readers may skip the body.
//!
//! A `Datum::Tuple` nests other non-`Tombstone` `Datum`s, including possibly other `Datum::Tuple`s.
//!
//! ```text
//! struct OptDatum::Tombstone {
//!     datum_type:         u8,
//! }
//!
//! struct Datum::I64 {
//!     datum_type:         u8,
//!     datum_body:         [u8; 8],
//! }
//!
//! struct Datum::Bytes or Datum::Str {
//!     datum_type:         u8,
//!     datum_body_len:     u32,
//!     datum_body:         [u8; datum_body_len],
//! }
//!
//! struct Datum::Tuple {
//!     datum_type:         u8,
//!     datum_body_len:     u32,
//!     datum_body:         {
//!         members_count:      u32,
//!         member_0:           Datum::I64 {
//!             datum_type:         u8,
//!             datum_body:         [u8; 8],
//!         },
//!         member_1:           Datum::Bytes or Datum::Str {
//!             datum_type:         u8,
//!             datum_body_len:     u32,
//!             datum_body:         [u8; datum_body_len],
//!         },
//!         member_2:           Datum::Tuple {
//!             datum_type:         u8,
//!             // (Notice, no datum_body_len here.)
//!             datum_body:         {
//!                 members_count:      u32,
//!                 member_0:           Datum::*,
//!                 ...
//!             }
//!         },
//!         member_3:           Datum::*
//!         ...
//!         // Tombstone may not be nested under Tuple.
//!     }
//! }
//! ```

mod datum;
mod datum_type;
mod lengths;

pub use datum::*;
pub use datum_type::*;
use lengths::*;