Trait airmash_protocol::Protocol[][src]

pub trait Protocol: Sync + Send {
    type SerializeError: Error;
    type DeserializeError: Error;
    fn version(&self) -> u8;
fn serialize_client(
        &self,
        packet: &ClientPacket
    ) -> Result<Box<Iterator<Item = Vec<u8>>>, Self::SerializeError>;
fn serialize_server(
        &self,
        packet: &ServerPacket
    ) -> Result<Box<Iterator<Item = Vec<u8>>>, Self::SerializeError>;
fn deserialize_client(
        &self,
        data: &[u8]
    ) -> Result<ClientPacket, Self::DeserializeError>;
fn deserialize_server(
        &self,
        data: &[u8]
    ) -> Result<ServerPacket, Self::DeserializeError>; }

Interface to implement for all protocols.

Associated Types

Required Methods

Unique version number for the protocol.

Serialize a client packet into some number of binary packet bodies.

For most packets this should be a 1-to-1 deserialization but the iterator return type is there to allow for polyfilling of the packets behind the scenes if a protocol backend doesn't support them directly. This can be used (for example) to send multiple packets for when more than 255 missiles are reflected with the same goliath deflect (which is not supported by protocol-v5).

For users of this interface it will most likely be more convienient to call ProtocolSerializationExt::serialize() with a ClientPacket instead, since it provides a unified interface to serializing a ClientPacket and a ServerPacket.

Panics

This method should never panic (based on the input), instead it should return an appropriate error within the SerializeError type.

Serialize a server packet into some number of binary packet bodies.

For most packets this should be a 1-to-1 deserialization but the iterator return type is there to allow for polyfilling of the packets behind the scenes if a protocol backend doesn't support them directly. This can be used (for example) to send multiple packets for when more than 255 missiles are reflected with the same goliath deflect (which is not supported by protocol-v5).

For users of this interface it will most likely be more convienient to call ProtocolSerializationExt::serialize() with a ServerPacket instead, since it provides a unified interface to serializing a ServerPacket and a ClientPacket.

Panics

This method should never panic (based on the input), instead it should return an appropriate error within the SerializeError type.

Deserialize a binary packet into a client packet.

Deserialize a binary packet into a server packet.

Implementors