diff options
| author | mat <github@matdoes.dev> | 2022-05-01 23:35:30 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-05-01 23:35:30 -0500 |
| commit | a24d00d99819166a147af77dc50ff61dff5cb04a (patch) | |
| tree | de2fc9ae04047e1dbfe6f343959907bdd2060b37 /azalea-protocol/packet-macros | |
| parent | bec2da64d81883e3ea909452e71e17b9d22b2adc (diff) | |
| download | azalea-drasl-a24d00d99819166a147af77dc50ff61dff5cb04a.tar.xz | |
impl Write instead of Vec<u8> for consistency
Diffstat (limited to 'azalea-protocol/packet-macros')
| -rwxr-xr-x | azalea-protocol/packet-macros/src/lib.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs index 0d912257..35abf642 100755 --- a/azalea-protocol/packet-macros/src/lib.rs +++ b/azalea-protocol/packet-macros/src/lib.rs @@ -123,7 +123,7 @@ fn create_impl_mcbufwritable(ident: &Ident, data: &Data) -> proc_macro2::TokenSt quote! { impl crate::mc_buf::McBufWritable for #ident { - fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> { #(#write_fields)* Ok(()) } @@ -133,7 +133,7 @@ fn create_impl_mcbufwritable(ident: &Ident, data: &Data) -> proc_macro2::TokenSt syn::Data::Enum(syn::DataEnum { .. }) => { quote! { impl crate::mc_buf::McBufWritable for #ident { - fn write_into(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> { crate::mc_buf::Writable::write_varint(buf, *self as i32) } } @@ -178,7 +178,7 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke #state::#ident(self) } - pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + pub fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> { crate::mc_buf::McBufWritable::write_into(self, buf) } @@ -366,7 +366,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream { } } - fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> { match self { #write_match_contents } |
