blob: 26321f34f966f314ee708a932609d0fcfd919080 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use std::{
hash::Hash,
io::{Read, Write},
};
use azalea_buf::{BufReadError, Readable, Writable};
use super::ClientboundLoginPacket;
#[derive(Hash, Clone, Debug)]
pub struct ClientboundLoginCompressionPacket {
pub compression_threshold: i32,
}
impl ClientboundLoginCompressionPacket {
pub fn get(self) -> ClientboundLoginPacket {
ClientboundLoginPacket::ClientboundLoginCompressionPacket(self)
}
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<ClientboundLoginPacket, BufReadError> {
let compression_threshold = buf.read_varint()?;
Ok(ClientboundLoginCompressionPacket {
compression_threshold,
}
.get())
}
}
|