substrate_data/wire/binary/tag.rs
1//! A value's first byte: what it is.
2
3/// The tags, each a constant, and [`ALL`] of them by name.
4macro_rules! tags {
5 ($($(#[$doc:meta])* $name:ident = $value:expr;)*) => {
6 $($(#[$doc])* pub const $name: u8 = $value;)*
7 /// Every tag, by its name (what other languages' readers are generated from).
8 pub const ALL: &[(&str, u8)] = &[$((stringify!($name), $value)),*];
9 };
10}
11
12tags! {
13 /// Null.
14 NULL = 0;
15 /// `false`.
16 FALSE = 1;
17 /// `true`.
18 TRUE = 2;
19 /// An integer, zigzag varint.
20 INT = 3;
21 /// A float, an `f64` little-endian.
22 FLOAT = 4;
23 /// A string: new (its bytes) or the table's.
24 STR = 5;
25 /// A list: a count, then the values.
26 LIST = 6;
27 /// A map: a count, then key and value pairs.
28 MAP = 7;
29 /// A reference: its kind and id strings.
30 REF = 8;
31 /// Bytes: a length, then them.
32 BYTES = 9;
33 /// A list of ints without a tag each: what a schema of numbers writes its lists as.
34 INTS = 10;
35 /// A list in a body of its own (its own strings): read lazily, cut out whole ([`crate::Stream`]).
36 STREAM = 11;
37 /// A float that is an `f32` exactly, 4 bytes.
38 FLOAT32 = 12;
39 /// Lists of floats without a tag each.
40 FLOATS = 13;
41 /// Lists of `f32`s without a tag each.
42 FLOATS32 = 14;
43}