airmash_protocol/
client_packet.rs

1use crate::client::*;
2
3/// All possible client packets.
4///
5/// This contains all valid packets that
6/// the client can send to the server
7/// (in the current version of the airmash
8/// protocol).
9///
10/// Some packets don't contain any data, these
11/// packets do not have an associated struct
12/// and as such are just empty variants within
13/// this enum.
14///
15/// The [`From`][0] trait has been implemented
16/// for all the structs that correspond to the
17/// variants of this enum. This means that instead
18/// of directly constructing an instance of
19/// `ClientPacket`, [`into()`][1] can be called
20/// instead.
21///
22/// [0]: https://doc.rust-lang.org/std/convert/trait.From.html
23/// [1]: https://doc.rust-lang.org/std/convert/trait.Into.html#tymethod.into
24#[derive(Clone, Debug)]
25#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
26#[non_exhaustive]
27pub enum ClientPacket {
28  Login(Login),
29  Backup(Backup),
30  Horizon(Horizon),
31  Ack,
32  Pong(Pong),
33  Key(Key),
34  Command(Command),
35  ScoreDetailed,
36  Chat(Chat),
37  TeamChat(TeamChat),
38  Whisper(Whisper),
39  Say(Say),
40  VoteMute(VoteMute),
41  LocalPing(LocalPing),
42}
43
44macro_rules! impl_from_newtype {
45  ($type:tt) => {
46    impl_from_newtype_inner!(ClientPacket, $type);
47  };
48}
49
50macro_rules! impl_from_empty {
51  ($type:tt) => {
52    impl_from_empty_inner!(ClientPacket, $type);
53  };
54}
55
56impl_from_newtype!(Login);
57impl_from_newtype!(Backup);
58impl_from_newtype!(Horizon);
59impl_from_newtype!(Pong);
60impl_from_newtype!(Key);
61impl_from_newtype!(Command);
62impl_from_newtype!(Chat);
63impl_from_newtype!(TeamChat);
64impl_from_newtype!(Whisper);
65impl_from_newtype!(Say);
66impl_from_newtype!(VoteMute);
67impl_from_newtype!(LocalPing);
68
69impl_from_empty!(Ack);
70impl_from_empty!(ScoreDetailed);