aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/azalea-protocol-macros/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-protocol/azalea-protocol-macros/src')
-rw-r--r--azalea-protocol/azalea-protocol-macros/src/lib.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/azalea-protocol/azalea-protocol-macros/src/lib.rs b/azalea-protocol/azalea-protocol-macros/src/lib.rs
index ecdabbca..b7e85435 100644
--- a/azalea-protocol/azalea-protocol-macros/src/lib.rs
+++ b/azalea-protocol/azalea-protocol-macros/src/lib.rs
@@ -30,7 +30,7 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
}
pub fn read(
- buf: &mut impl std::io::Read,
+ buf: &mut std::io::Cursor<&[u8]>,
) -> Result<#state, azalea_buf::BufReadError> {
use azalea_buf::McBufReadable;
Ok(Self::read_from(buf)?.get())
@@ -223,7 +223,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
#id => {
let data = #module::#name::read(buf).map_err(|e| crate::read::ReadPacketError::Parse { source: e, packet_id: #id, packet_name: #name_litstr.to_string() })?;
let mut leftover = Vec::new();
- let _ = buf.read_to_end(&mut leftover);
+ let _ = std::io::Read::read_to_end(buf, &mut leftover);
if !leftover.is_empty() {
return Err(crate::read::ReadPacketError::LeftoverData { packet_name: #name_litstr.to_string(), data: leftover });
}
@@ -250,9 +250,10 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
#[cfg(debug_assertions)]
{
let mut leftover = Vec::new();
- let _ = buf.read_to_end(&mut leftover);
+ let _ = std::io::Read::read_to_end(buf, &mut leftover);
if !leftover.is_empty() {
return Err(crate::read::ReadPacketError::LeftoverData { packet_name: #name_litstr.to_string(), data: leftover });
+
}
}
data
@@ -312,7 +313,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
/// Read a packet by its id, ConnectionProtocol, and flow
fn read(
id: u32,
- buf: &mut impl std::io::Read,
+ buf: &mut std::io::Cursor<&[u8]>,
) -> Result<#serverbound_state_name, crate::read::ReadPacketError>
where
Self: Sized,
@@ -343,7 +344,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
/// Read a packet by its id, ConnectionProtocol, and flow
fn read(
id: u32,
- buf: &mut impl std::io::Read,
+ buf: &mut std::io::Cursor<&[u8]>,
) -> Result<#clientbound_state_name, crate::read::ReadPacketError>
where
Self: Sized,