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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105

//! **THIS LIBRARY IS IN ALPHA!**
//! **USE AT YOUR OWN RISK**
//! 
//! This library contains definitions 
//! and serialization/deserialization methods
//! for the protocol for the game 
//! [`AIRMASH`](https://airma.sh). It implements
//! serialization and deserialization and is 
//! intended to be used for creating bots or 
//! servers using this protocol.
//! 
//! # Basic Usage
//! Serialization and deserialization of packets
//! is simple on the caller's side. All that
//! must be done is to call 
//! [`from_bytes`](fn.from_bytes.html) to
//! deserialize and to call
//! [`to_bytes`](fn.to_bytes.html) to serialize.
//! The [`ServerPacket`](server/struct.serverpacket.html)
//! and [`ClientPacket`](client/struct.clientpacket.html)
//! structs will take care of decoding the message 
//! type and message fields for you as well as 
//! encoding them. If an invalid message is passed 
//! then deserialize will return an error indicating
//! what went wrong. (Note: it will currently panic
//! in some cases. See TODOs). If an error occurse while
//! serializing, an error will be returned too. 
//! (Note: will panic currently. See TODOs).
//! 
//! # Client-Side
//! Clients using this library will be deserializing
//! packets into the 
//! [`ServerPacket`](server/enum.serverpacket.html)
//! enum and will be responding by serializing
//! [`ClientPacket`](client/enum.clientpacket.html)s
//! and sending those to the server.
//! 
//! # Server-Side
//! Servers using this library will be doing the 
//! opposite of clients. They will deserialize
//! [`ServerPacket`](server/enum.serverpacket.html)s
//! and will be serializing
//! [`ClientPacket`](client/enum.clientpacket.html)s.
//! 
//! # Use with Serde
//! All protocol types are able to be serialized and 
//! deserialized using serde. This is not enabled
//! by default, but can be enabled by turning on
//! the feature `"serde"`. Note that serde is not 
//! required for regular use of the library.
//! 


// # TODOs
// There is still a bunch of things that can be 
// improved within the library:
// 
// - Change teams to an enum. (Currently a `u8`)
// - Complete packet field documentation/figure out
//   what all packet fields actually do.
// - Complete documentation of BTR 
//   [`ServerCustom`](server/struct.servercustom.html)
//   data format.
// - Write unit tests for all serialization and deserialization
//   groups within [`field.rs`](../src/airmash_protocol/field.rs.html).
// - More internal documentation on specific protocol data types.
//   This should probably go within 
//   [`field.rs`](../src/airmash_protocol/field.rs.html) too.
// 

#[cfg_attr(feature="serde", macro_use)]
#[cfg(feature="serde")]
extern crate serde;
extern crate phf;

#[macro_use]
mod macros;

mod serde_am;

mod de;
mod error;
mod field;
mod ser;

mod impls;
mod packet_impls;
mod codes;

mod datatypes;

mod field_tests;

pub mod client;
pub mod server;

pub use ser::to_bytes;
pub use de::from_bytes;
pub use error::Error;

pub use client::ClientPacket;
pub use server::ServerPacket;

pub use datatypes::*;