diff options
| author | mat <github@matdoes.dev> | 2022-05-01 23:35:30 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-05-01 23:38:55 -0500 |
| commit | dedcd0de8f017a00645b31cfdc1819a4e8da0850 (patch) | |
| tree | 7005291337dcc5a9cd1c5bb71668b511a6834d23 /azalea-protocol/src/packets/login | |
| parent | db2fcecdc38ea7a43b098c6282dd906b73981f97 (diff) | |
| download | azalea-drasl-dedcd0de8f017a00645b31cfdc1819a4e8da0850.tar.xz | |
impl Write instead of Vec<u8> for consistency
Diffstat (limited to 'azalea-protocol/src/packets/login')
3 files changed, 14 insertions, 8 deletions
diff --git a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs index bcdcd105..dd077ced 100755 --- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs @@ -1,4 +1,4 @@ -use std::io::Read; +use std::io::{Read, Write}; use super::LoginPacket; use crate::mc_buf::{Readable, Writable}; @@ -17,7 +17,7 @@ impl ClientboundGameProfilePacket { LoginPacket::ClientboundGameProfilePacket(self) } - pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { for n in self.game_profile.uuid.to_int_array() { buf.write_int(n as i32).unwrap(); } diff --git a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs index 06f346c2..f7de4c21 100755 --- a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs @@ -1,4 +1,7 @@ -use std::{hash::Hash, io::Read}; +use std::{ + hash::Hash, + io::{Read, Write}, +}; use super::LoginPacket; use crate::mc_buf::Readable; @@ -15,11 +18,11 @@ impl ClientboundHelloPacket { LoginPacket::ClientboundHelloPacket(self) } - pub fn write(&self, _buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + pub fn write(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { panic!("ClientboundHelloPacket::write not implemented") } - pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> { + pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> { let server_id = buf.read_utf_with_len(20)?; let public_key = buf.read_byte_array()?; let nonce = buf.read_byte_array()?; diff --git a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs index a5ab78bb..b1323f50 100755 --- a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs @@ -1,4 +1,7 @@ -use std::{hash::Hash, io::Read}; +use std::{ + hash::Hash, + io::{Read, Write}, +}; use crate::mc_buf::{Readable, Writable}; @@ -14,12 +17,12 @@ impl ClientboundLoginCompressionPacket { LoginPacket::ClientboundLoginCompressionPacket(self) } - pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + pub fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { buf.write_varint(self.compression_threshold).unwrap(); Ok(()) } - pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> { + pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> { let compression_threshold = buf.read_varint()?; Ok(ClientboundLoginCompressionPacket { |
