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
//! Protocol definitions for AIRMASH. This crate provides a strongly typed
//! interface for communicating with an airmash server. It also provides an
//! implementation of the airmash v5 protocol along with serde definitions for
//! all interface structs. This is enough to communicate with any existing
//! airmash server over a websocket connection.
//!
//! # Library Usage
//! The library is designed to be straightforward to use. First construct the
//! appropriate packet from either [server packets](crate::ServerPacket) or
//! [client packets](crate::ClientPacket). From there you can serialize it to
//! bytes via [`v5::serialize`](crate::v5::serialize).
//!
//! ```
//! # use airmash_protocol::{ClientPacket, KeyCode, v5, client::Key};
//! # fn main() -> Result<(), v5::Error> {
//! let packet = ClientPacket::from(Key {
//! seq: 0,
//! key: KeyCode::Fire,
//! state: true
//! });
//!
//! let bytes = airmash_protocol::v5::serialize(&packet)?;
//! // ... send bytes to server
//! # Ok(())
//! # }
//! ```
//!
//! Note that while the individual packet types are serializable individually
//! the only types expected to be passed between clients and servers are
//! [`ServerPacket`] and [`ClientPacket`].
//!
//! For deserialization you can use [`v5::deserialize`] on any byte slice.
//! ```
//! # use airmash_protocol::{ClientPacket, v5};
//! # fn get_some_bytes() -> Vec<u8> { return vec![5]; }
//! # fn main() -> Result<(), v5::Error> {
//! let bytes: Vec<u8> = get_some_bytes();
//! let packet: ClientPacket = airmash_protocol::v5::deserialize(&bytes)?;
//! // ... do stuff with packet
//! # Ok(())
//! # }
//! ```
extern crate serde;
pub use ClientPacket;
pub use *;
pub use *;
pub use ServerPacket;
pub use *;
pub use crateEnumValueOutOfRangeError;