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
//! Wire-format constants shared by the encoder and decoder.
//!
//! This module is the single source of truth for the binary wire layout:
//! value tags, container terminators, and marker-varint prefixes. Both the
//! encoder (`ser`) and the decoder (`decoder`) import these instead of
//! re-declaring them, so the two directions can never drift apart.
/// `null` (unit / `Option::None`).
pub const TAG_NULL: u8 = 0x00;
/// `false`.
pub const TAG_FALSE: u8 = 0x01;
/// `true`.
pub const TAG_TRUE: u8 = 0x02;
/// `u64`.
pub const TAG_U64: u8 = 0x03;
/// `u128`.
pub const TAG_U128: u8 = 0x04;
/// `i64`.
pub const TAG_I64: u8 = 0x05;
/// `i128`.
pub const TAG_I128: u8 = 0x06;
/// `f64`.
pub const TAG_F64: u8 = 0x07;
/// `f32`.
pub const TAG_F32: u8 = 0x08;
/// String / char (length + UTF-8).
pub const TAG_STRING: u8 = 0x09;
/// Array (elements, then `TAG_END`).
pub const TAG_ARRAY: u8 = 0x0a;
/// Object (`key` + value pairs, then `TAG_END`).
pub const TAG_OBJECT: u8 = 0x0b;
/// End-of-container terminator. Never a valid value tag.
pub const TAG_END: u8 = 0xff;
/// Marker prefix for a 16-bit marker-varint payload (`251..=0xffff`).
pub const MARKER_U16: u8 = 251;
/// Marker prefix for a 32-bit marker-varint payload (`0x1_0000..=0xffff_ffff`).
pub const MARKER_U32: u8 = 252;
/// Marker prefix for a 64-bit marker-varint payload (`0x1_0000_0000..=0xffff_ffff_ffff_ffff`).
pub const MARKER_U64: u8 = 253;
/// Marker prefix for a 128-bit marker-varint payload (`>= 0x1_0000_0000_0000_0000`).
pub const MARKER_U128: u8 = 254;
/// Maximum container nesting depth enforced by both encoder and decoder.
///
/// This must be identical on both sides: it sizes the per-depth element-count
/// tables, so a drift would let one direction accept frames the other rejects
/// (or vice versa). Mirrors nextjson's default decode depth.
pub const MAX_DEPTH: usize = 128;