Trait airmash_protocol::ProtocolSerializationExt [−][src]
pub trait ProtocolSerializationExt<T>: Protocol { fn serialize<U>(
&self,
packet: U
) -> Result<Box<Iterator<Item = Vec<u8>>>, Self::SerializeError>
where
U: Into<T>; fn deserialize(&self, data: &[u8]) -> Result<T, Self::DeserializeError>; }
Helper trait to make working with protocols easier.
This allows for ServerPacket
and
ClientPacket
to be serialized and deserialized
without using the serialize_*
or deserialize_*
methods within the Protocol
trait. Instead they
can use serialize
and deserialize
and
let type inference deduce the correct type.
This trait should not be implemented by client code.
Required Methods
fn serialize<U>(
&self,
packet: U
) -> Result<Box<Iterator<Item = Vec<u8>>>, Self::SerializeError> where
U: Into<T>,
&self,
packet: U
) -> Result<Box<Iterator<Item = Vec<u8>>>, Self::SerializeError> where
U: Into<T>,
fn deserialize(&self, data: &[u8]) -> Result<T, Self::DeserializeError>
Implementors
impl<T> ProtocolSerializationExt<ServerPacket> for T where
T: Protocol + Sync + Send,impl<T> ProtocolSerializationExt<ClientPacket> for T where
T: Protocol + Sync + Send,