diff options
author | Joey Sacchini <joey@sacchini.net> | 2020-10-22 09:39:26 -0400 |
---|---|---|
committer | Joey Sacchini <joey@sacchini.net> | 2020-10-22 09:39:26 -0400 |
commit | e94567e0ad68ec3407b37ed40eaaff9943947405 (patch) | |
tree | d6f6f5a110bd0aa9e50ea888de342c12aa30f5bf /src/v1_15_2.rs | |
parent | c32e6abbbf06265cff0079de3aaa1cec8d17701d (diff) | |
download | mcproto-rs-e94567e0ad68ec3407b37ed40eaaff9943947405.tar.gz mcproto-rs-e94567e0ad68ec3407b37ed40eaaff9943947405.tar.bz2 mcproto-rs-e94567e0ad68ec3407b37ed40eaaff9943947405.zip |
move RemainingBytes out of the protocol definitions and refactor some duplication in chat.rs
Diffstat (limited to 'src/v1_15_2.rs')
-rw-r--r-- | src/v1_15_2.rs | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/v1_15_2.rs b/src/v1_15_2.rs index 1f2f005..402d853 100644 --- a/src/v1_15_2.rs +++ b/src/v1_15_2.rs @@ -710,53 +710,6 @@ proto_byte_enum!(HandshakeNextState, 0x02 :: Login ); -#[derive(Debug, Clone, PartialEq)] -pub struct RemainingBytes { - pub data: Vec<u8>, -} - -impl Serialize for RemainingBytes { - fn mc_serialize<S: Serializer>(&self, to: &mut S) -> SerializeResult { - to.serialize_bytes(self.data.as_slice()) - } -} - -impl Deserialize for RemainingBytes { - fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> { - Deserialized::ok( - RemainingBytes { - data: Vec::from(data), - }, - &[], - ) - } -} - -impl Into<Vec<u8>> for RemainingBytes { - fn into(self) -> Vec<u8> { - self.data - } -} - -impl From<Vec<u8>> for RemainingBytes { - fn from(data: Vec<u8>) -> Self { - Self { data } - } -} - -#[cfg(all(test, feature = "std"))] -impl TestRandom for RemainingBytes { - fn test_gen_random() -> Self { - let size: usize = rand::random::<usize>() % 256; - let mut out = Vec::with_capacity(size); - for _ in 0..size { - out.push(rand::random()); - } - - Self { data: out } - } -} - proto_byte_enum!(CardinalDirection, 0x00 :: South, 0x01 :: West, |