mid_net/
proto.rs

1use integral_enum::IntegralEnum;
2use thiserror::Error;
3
4#[derive(IntegralEnum)]
5pub enum Protocol {
6    Tcp = 0,
7    Udp = 1,
8}
9
10#[derive(IntegralEnum)]
11pub enum PacketType {
12    Failure = 0,
13    Ping = 1,
14
15    Connect = 2,
16    Forward = 3,
17    Disconnect = 4,
18
19    CreateServer = 5,
20
21    Authorize = 6,
22    UpdateRights = 7,
23}
24
25#[derive(IntegralEnum, Error)]
26pub enum ProtocolError {
27    #[error("Unknown packet sent")]
28    UnknownPacket = 0,
29
30    #[error("Unexpected packet for that side")]
31    UnexpectedPacket = 1,
32
33    #[error("Functionality currently is not implemented")]
34    Unimplemented = 2,
35
36    #[error("You don't have access to this functionality")]
37    AccessDenied = 3,
38
39    #[error("Functionality is disabled")]
40    Disabled = 4,
41
42    #[error("Failed to create TCP listener")]
43    FailedToCreateListener = 5,
44
45    #[error("Failed to retrieve listening port")]
46    FailedToRetrievePort = 6,
47
48    #[error("The server is already created")]
49    AlreadyCreated = 7,
50
51    #[error("The server is not created")]
52    ServerIsNotCreated = 8,
53
54    #[error("Client does not exists")]
55    ClientDoesNotExists = 9,
56
57    #[error("Decompression of payload failed")]
58    DecompressionFailed = 10,
59
60    #[error("Created server was shut down")]
61    ServerWasShutDown = 11,
62}