diff options
Diffstat (limited to 'azalea-protocol/src/mc_buf/write.rs')
| -rwxr-xr-x | azalea-protocol/src/mc_buf/write.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index f1362402..e8845f25 100755 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -1,5 +1,4 @@ -use super::MAX_STRING_LENGTH; -use crate::mc_buf::ByteArray; +use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use async_trait::async_trait; use azalea_chat::component::Component; use azalea_core::{ @@ -187,15 +186,17 @@ impl McBufVarintWritable for i32 { } } -impl McBufWritable for Vec<u8> { +impl McBufWritable for UnsizedByteArray { fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { buf.write_bytes(self) } } -impl McBufWritable for ByteArray { +// TODO: use specialization when that gets stabilized into rust +// to optimize for Vec<u8> byte arrays +impl<T: McBufWritable> McBufWritable for Vec<T> { fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { - buf.write_byte_array(&self) + buf.write_list(self, |buf, i| T::write_into(i, buf)) } } @@ -304,15 +305,6 @@ impl McBufWritable for Option<GameType> { } } -// Vec<ResourceLocation> -impl McBufWritable for Vec<ResourceLocation> { - fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { - buf.write_list(self, |buf, resource_location| { - buf.write_resource_location(resource_location) - }) - } -} - // azalea_nbt::Tag impl McBufWritable for azalea_nbt::Tag { fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { |
