-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.protodecl
53 lines (37 loc) · 1.19 KB
/
example.protodecl
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
// This is Single-line comments
/*
This is Multi-line comments
*/
// Primitive types
//
// Boolean: bool (true or false)
// Integer: u8, i8, u16, i16, u32, i32, u64, i64, u128, i128
// String: CString, String, CBytes, Bytes (maxsize: u32)
// LongString: LongString, LongBytes (maxsize: u64)
// SizedString: String8le, String16le, String32le, String64le, String8be, String16be, String32be, String64be
// SizedBytes: Bytes8le, Bytes16le, Bytes32le, Bytes64le, Bytes8be, Bytes16be, Bytes32be, Bytes64be
// Float: f32, f64
// Array: Array(Type, size)
// Padding: Padding(size) // size is the number of bits to pad
// Bits: Bits(size) // size is the number of bits
// This is a Number Literals
// 42, 0x2A, 0b00101010, '*'
// This is an Enumeration Declaration
enum SomeEnumeration u8 {
// Enumeration definition goes here
Case0 = 0x00;
Case1 = 0x01;
Case2 = 0x02;
Case3 = 0x03;
}
// This is a Packet Structure Declaration
packet MyPacket(packet_id: u8) {
// Packet structure defianition goes here
Bits(2) protocol_version;
Bits(2) packet_type;
Bits(2) packet_flags;
Padding(2) _;
SomeEnumeration some_enum;
u32 string_size;
String(string_size) string;
}