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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//! Definition of the primitive types

mod array;
mod binary_ref;
mod decimal;
mod map;
mod symbol;
mod timestamp;
mod uuid;

// to avoid ambiguity
pub use crate::primitives::array::*;
pub use crate::primitives::binary_ref::*;
pub use crate::primitives::decimal::*;
pub use crate::primitives::map::*;
pub use crate::primitives::symbol::*;
pub use crate::primitives::timestamp::*;
pub use crate::primitives::uuid::*;

// Alias for the primitive types to match those in the spec
use serde_bytes::ByteBuf;

/// Represents a true or false value
///
/// encoding code = 0x56
/// category = fixed, width = 1
/// label = "boolean with the octet 0x00 being false and octet 0x01 being true"
///
/// encoding name = "true", encoding code = 0x41
/// category = fixed, width = 0
/// label = "the boolean value true"
///
/// encoding name = "false", encoding code = 0x42
/// category = fixed, width = 0
/// label = "the boolean value false"
pub type Boolean = bool;

/// Integer in the range 0 to 2^8-1 inclusive
///
/// encoding code = 0x50,
/// category = fixed, width = 1
/// label = "8-bit unsigned integer"
pub type Ubyte = u8;

/// Integer in the range 0 to 2^16-1 inclusive
///
/// encoding code = 0x60,
/// category = fixed, width = 2
/// label = "16-bit unsigned integer in network byte order"
/// (AKA. Big-Endian, rust uses BigEndian by default)
pub type Ushort = u16;

/// Integer in the range 0 to 2^32-1 inclusive
///
/// encoding code = 0x70,
/// category = fixed, width = 4
/// label = "32-bit unsigned integer in network byte order"
/// (AKA. Big-Endian, rust uses BigEndian by default)
///
/// encoding name = "smalluint", encoding code = 0x52
/// category = fixed, width = 1
/// label = "unsigned integer value in the range 0 to 255 inclusive"
///
/// encoding name = "uint0", encoding code = 0x43
/// category = fixed, width = 0
/// label = "the uint value 0"
pub type Uint = u32;

/// Integer in the range 0 to 2^64-1 inclusive
///
/// encoding code = 0x80,
/// category = fixed, width = 8
/// label = "64-bit unsigned integer in network byte order"
/// (AKA. Big-Endian, rust uses BigEndian by default)
///
/// encoding name = "smallulong", encoding code = 0x53
/// category = fixed, width = 1
/// label = "unsigned long value in the range 0 to 255 inclusive"
///
/// encoding name = "ulong0", encoding code = 0x44
/// category = fixed, width = 0
/// label = "the ulong value 0"
pub type Ulong = u64;

/// Integer in the range -(2^7) to 2^7-1 inclusive
///
/// encoding code = 0x51,
/// category = fixed, width = 1
/// label = "8-bit two's-complement integer"
pub type Byte = i8;

/// Integer in the range -(2^15) to 2^15-1 inclusive
///
/// encoding code = 0x61,
/// category = fixed, width = 2
/// label = "16-bit two’s-complement integer in network byte order"
pub type Short = i16;

/// Integer in the range -(2^31) to 2^31-1 inclusive
///
/// encoding code = 0x71,
/// category = fixed, width = 4
/// label = "32-bit two’s-complement integer in network byte order"
///
/// encoding name = "smallint", encoding code = 0x54
/// category = fixed, width = 1
/// label = "8-bit two’s-complement integer"
pub type Int = i32;

/// Integer in the range -(2^63) to 2^63-1 inclusive
///
/// encoding code = 0x81,
/// category = fixed, width = 8
/// label = "64-bit two’s-complement integer in network byte order"
///
/// encoding name = "smalllong", encoding code = 0x55
/// category = fixed, width = 1
/// label = "8-bit two’s-complement integer"
pub type Long = i64;

/// 32-bit floating point number (IEEE 754-2008 binary32)
///
/// encoding name = "ieee-754", encoding code = 0x72
/// category = fixed, width = 4
/// label = "IEEE 754-2008 binary32"
pub type Float = f32;

/// 64-bit floating point number (IEEE 754-2008 binary64).
///
/// encoding name = "ieee-754", encoding code = 0x82
/// category = fixed, width = 8
/// label = "IEEE 754-2008 binary64"
pub type Double = f64;

/// A single Unicode character
///
/// encoding name = "utf32", encoding code = 0x73
/// category = fixed, width = 4,
/// label = "a UTF-32BE encoded Unicode character"
pub type Char = char;

/// A sequence of octets.
///
/// encoding name = "vbin8", encoding code = 0xa0
/// category = variable, width = 1
/// label = "up to 2^8 - 1 octets of binary data"
///
/// encoding name = "vbin32", encoding code = 0xb0,
/// category = variable, width = 4,
/// label="up to 2^32 - 1 octets of binary data"
pub type Binary = ByteBuf;

/// A sequence of polymorphic values.
pub type List<T> = Vec<T>;