aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/login
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-01-01 23:55:19 -0600
committermat <github@matdoes.dev>2022-01-01 23:55:19 -0600
commita1afbb6031527c1db5831fc8e916bc0ecce633b4 (patch)
tree56fbccf52645cc2eefd231506ffe8ed71018dc01 /azalea-protocol/src/packets/login
parente81b85dd5bdd6d42ee84f24ed4a142f6141f170e (diff)
downloadazalea-drasl-a1afbb6031527c1db5831fc8e916bc0ecce633b4.tar.xz
start adding packet macros
Diffstat (limited to 'azalea-protocol/src/packets/login')
-rw-r--r--azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs3
-rw-r--r--azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs3
-rw-r--r--azalea-protocol/src/packets/login/clientbound_hello_packet.rs2
-rw-r--r--azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs3
-rw-r--r--azalea-protocol/src/packets/login/mod.rs2
-rw-r--r--azalea-protocol/src/packets/login/serverbound_hello_packet.rs3
6 files changed, 10 insertions, 6 deletions
diff --git a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
index 048fa53f..22e58b0d 100644
--- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
@@ -15,10 +15,11 @@ impl ClientboundCustomQueryPacket {
LoginPacket::ClientboundCustomQueryPacket(self)
}
- pub fn write(&self, buf: &mut Vec<u8>) {
+ pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
buf.write_varint(self.transaction_id as i32).unwrap();
buf.write_utf(self.identifier.to_string().as_str()).unwrap();
buf.write_bytes(&self.data).unwrap();
+ Ok(())
}
pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
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 1a752c1a..c54aa819 100644
--- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
@@ -14,11 +14,12 @@ impl ClientboundGameProfilePacket {
LoginPacket::ClientboundGameProfilePacket(self)
}
- pub fn write(&self, buf: &mut Vec<u8>) {
+ pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
for n in self.game_profile.uuid.to_int_array() {
buf.write_int(n as i32).unwrap();
}
buf.write_utf(self.game_profile.name.as_str()).unwrap();
+ Ok(())
}
pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
diff --git a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
index e0b865be..9d0cec39 100644
--- a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
@@ -16,7 +16,7 @@ impl ClientboundHelloPacket {
LoginPacket::ClientboundHelloPacket(self)
}
- pub fn write(&self, _buf: &mut Vec<u8>) {
+ pub fn write(&self, _buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
panic!("ClientboundHelloPacket::write not implemented")
}
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 af355192..a88c6cbf 100644
--- a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
@@ -14,8 +14,9 @@ impl ClientboundLoginCompressionPacket {
LoginPacket::ClientboundLoginCompressionPacket(self)
}
- pub fn write(&self, buf: &mut Vec<u8>) {
+ pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
buf.write_varint(self.compression_threshold).unwrap();
+ Ok(())
}
pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
diff --git a/azalea-protocol/src/packets/login/mod.rs b/azalea-protocol/src/packets/login/mod.rs
index 4d490d08..b1f61746 100644
--- a/azalea-protocol/src/packets/login/mod.rs
+++ b/azalea-protocol/src/packets/login/mod.rs
@@ -34,7 +34,7 @@ impl ProtocolPacket for LoginPacket {
}
}
- fn write(&self, buf: &mut Vec<u8>) {
+ fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
match self {
LoginPacket::ClientboundCustomQueryPacket(packet) => packet.write(buf),
LoginPacket::ClientboundGameProfilePacket(packet) => packet.write(buf),
diff --git a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
index 0039cbce..a72480f2 100644
--- a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
@@ -14,8 +14,9 @@ impl ServerboundHelloPacket {
LoginPacket::ServerboundHelloPacket(self)
}
- pub fn write(&self, buf: &mut Vec<u8>) {
+ pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
buf.write_utf(&self.username).unwrap();
+ Ok(())
}
pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(