Crate airmash_protocol [] [src]

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. 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 to deserialize and to call to_bytes to serialize. The ServerPacket and ClientPacket 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 enum and will be responding by serializing ClientPackets and sending those to the server.

Server-Side

Servers using this library will be doing the opposite of clients. They will deserialize ServerPackets and will be serializing ClientPackets.

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.

Re-exports

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

Modules

client

Messages sent from client to server

server

Messages sent from server to client

Enums

Error

All the errors that can occur when serializing or deserializing messages within the airmash protocol.

FlagCode

All the current flags present within the airmash server.

KeyCode

All the keys that are sent from the client to the server.

KeyState

The current state of a key.

PlaneType

All plane types present within airmash.

Functions

from_bytes

Deserializes a struct from a byte buffer, and returns an Error when the bytes cannot be deserialized to the given type.

to_bytes

Serializes a struct to a byte vector, returning an Error when the struct cannot be serialized.