//! This crate implements Minecraft protocol. //! //! Information about protocol can be found at https://wiki.vg/Protocol. pub mod data; pub mod decoder; pub mod encoder; pub mod error; pub mod version; /// Protocol limits maximum string length. const STRING_MAX_LENGTH: u16 = 32_768; #[macro_export] macro_rules! impl_json_encoder_decoder ( ($ty: ident) => ( impl crate::encoder::Encoder for $ty { fn encode(&self, writer: &mut W) -> Result<(), crate::error::EncodeError> { let json = serde_json::to_string(self)?; crate::encoder::EncoderWriteExt::write_string(writer, &json, crate::STRING_MAX_LENGTH)?; Ok(()) } } impl crate::decoder::Decoder for $ty { type Output = Self; fn decode(reader: &mut R) -> Result { let json = crate::decoder::DecoderReadExt::read_string(reader, crate::STRING_MAX_LENGTH)?; Ok(serde_json::from_str(&json)?) } } ); );