Skip to main content

reliakit_codec/
format.rs

1//! Canonical binary format rules.
2//!
3//! Version 0.1 intentionally defines one binary representation per supported
4//! value:
5//!
6//! - integers are fixed-width little-endian,
7//! - `bool` is exactly `0x00` or `0x01`,
8//! - strings are UTF-8 bytes prefixed by a `u32` little-endian byte length,
9//! - vectors are prefixed by a `u32` little-endian item count,
10//! - `Option<T>` and `Result<T, E>` use one-byte tags,
11//! - fixed arrays and tuples encode fields in declaration order.
12//!
13//! Floats, pointer-sized integers, hash maps, unordered maps, schema
14//! negotiation, and non-canonical alternatives are not part of this initial
15//! format. They are omitted because their representation or ordering can be
16//! platform-dependent, ambiguous, or outside this crate's first-version scope.
17//!
18//! Generic fixed-array decoding (`[T; N]`) requires the `alloc` feature in this
19//! version because the crate forbids unsafe code and Rust 1.85 does not provide
20//! a stable fallible array initializer. In no-alloc builds, `[u8; N]` decoding is
21//! available because it can be filled directly from the source without heap
22//! allocation.
23
24/// Tag used for `false`.
25pub const BOOL_FALSE: u8 = 0x00;
26/// Tag used for `true`.
27pub const BOOL_TRUE: u8 = 0x01;
28/// Tag used for `None`.
29pub const OPTION_NONE: u8 = 0x00;
30/// Tag used for `Some`.
31pub const OPTION_SOME: u8 = 0x01;
32/// Tag used for `Ok`.
33pub const RESULT_OK: u8 = 0x00;
34/// Tag used for `Err`.
35pub const RESULT_ERR: u8 = 0x01;