airmash_protocol/
server_packet.rs

1use crate::server::*;
2
3/// All possible server packets.
4///
5/// This is an enum of all possible packet message types. Some packets do not
6/// contain any data and thus do not have any data within their enum variants.
7///
8/// The [`From`][0] trait has been implemented for all the structs that
9/// correspond to the variants of this enum. This means that instead of directly
10/// constructing an instance of `ServerPacket`, [`into()`][1] can be called
11/// instead.
12///
13/// [0]: https://doc.rust-lang.org/std/convert/trait.From.html
14/// [1]: https://doc.rust-lang.org/std/convert/trait.Into.html#tymethod.into
15#[derive(Clone, Debug)]
16#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
17#[non_exhaustive]
18pub enum ServerPacket {
19  Login(Login),
20  Login2(Login2),
21  Backup,
22  Ping(Ping),
23  PingResult(PingResult),
24  Ack,
25  Error(Error),
26  CommandReply(CommandReply),
27  PlayerNew(PlayerNew),
28  PlayerLeave(PlayerLeave),
29  PlayerUpdate(PlayerUpdate),
30  PlayerFire(PlayerFire),
31  PlayerRespawn(PlayerRespawn),
32  PlayerFlag(PlayerFlag),
33  PlayerHit(PlayerHit),
34  PlayerKill(PlayerKill),
35  PlayerUpgrade(PlayerUpgrade),
36  PlayerType(PlayerType),
37  PlayerPowerup(PlayerPowerup),
38  PlayerLevel(PlayerLevel),
39  PlayerReteam(PlayerReteam),
40  GameFlag(GameFlag),
41  GameSpectate(GameSpectate),
42  GamePlayersAlive(GamePlayersAlive),
43  GameFirewall(GameFirewall),
44  EventRepel(EventRepel),
45  EventBoost(EventBoost),
46  EventBounce(EventBounce),
47  EventStealth(EventStealth),
48  EventLeaveHorizon(EventLeaveHorizon),
49  MobUpdate(MobUpdate),
50  MobUpdate2(MobUpdate2),
51  MobUpdateStationary(MobUpdateStationary),
52  MobDespawn(MobDespawn),
53  MobDespawnCoords(MobDespawnCoords),
54  ScoreUpdate(ScoreUpdate),
55  ScoreBoard(ScoreBoard),
56  ScoreDetailedFFA(ScoreDetailedFFA),
57  ScoreDetailedCTF(ScoreDetailedCTF),
58  ScoreDetailedBTR(ScoreDetailedBTR),
59  ChatTeam(ChatTeam),
60  ChatPublic(ChatPublic),
61  ChatSay(ChatSay),
62  ChatWhisper(ChatWhisper),
63  ChatVoteMutePassed(ChatVoteMutePassed),
64  ChatVoteMuted,
65  ServerMessage(ServerMessage),
66  ServerCustom(ServerCustom),
67}
68
69macro_rules! impl_from_newtype {
70  ($type:tt) => {
71    impl_from_newtype_inner!(ServerPacket, $type);
72  };
73}
74
75macro_rules! impl_from_empty {
76  ($type:tt) => {
77    impl_from_empty_inner!(ServerPacket, $type);
78  };
79}
80
81impl_from_newtype!(Login);
82impl_from_newtype!(Login2);
83impl_from_newtype!(Ping);
84impl_from_newtype!(PingResult);
85impl_from_newtype!(Error);
86impl_from_newtype!(CommandReply);
87impl_from_newtype!(PlayerNew);
88impl_from_newtype!(PlayerLeave);
89impl_from_newtype!(PlayerUpdate);
90impl_from_newtype!(PlayerFire);
91impl_from_newtype!(PlayerRespawn);
92impl_from_newtype!(PlayerFlag);
93impl_from_newtype!(PlayerHit);
94impl_from_newtype!(PlayerKill);
95impl_from_newtype!(PlayerUpgrade);
96impl_from_newtype!(PlayerType);
97impl_from_newtype!(PlayerPowerup);
98impl_from_newtype!(PlayerLevel);
99impl_from_newtype!(PlayerReteam);
100impl_from_newtype!(GameFlag);
101impl_from_newtype!(GameSpectate);
102impl_from_newtype!(GamePlayersAlive);
103impl_from_newtype!(GameFirewall);
104impl_from_newtype!(EventRepel);
105impl_from_newtype!(EventBoost);
106impl_from_newtype!(EventBounce);
107impl_from_newtype!(EventStealth);
108impl_from_newtype!(EventLeaveHorizon);
109impl_from_newtype!(MobUpdate);
110impl_from_newtype!(MobUpdate2);
111impl_from_newtype!(MobUpdateStationary);
112impl_from_newtype!(MobDespawn);
113impl_from_newtype!(MobDespawnCoords);
114impl_from_newtype!(ScoreUpdate);
115impl_from_newtype!(ScoreBoard);
116impl_from_newtype!(ScoreDetailedFFA);
117impl_from_newtype!(ScoreDetailedCTF);
118impl_from_newtype!(ScoreDetailedBTR);
119impl_from_newtype!(ChatTeam);
120impl_from_newtype!(ChatPublic);
121impl_from_newtype!(ChatSay);
122impl_from_newtype!(ChatWhisper);
123impl_from_newtype!(ChatVoteMutePassed);
124impl_from_newtype!(ServerMessage);
125impl_from_newtype!(ServerCustom);
126
127impl_from_empty!(Backup);
128impl_from_empty!(Ack);
129impl_from_empty!(ChatVoteMuted);