ghast_protocol/generated/defs/p47/login/
clientbound.rs1#![allow(
9 unused_imports,
10 unused_variables,
11 unused_mut,
12 unused_parens,
13 unused_braces,
14 clippy::all,
15 clippy::pedantic,
16 non_camel_case_types,
17 non_snake_case
18)]
19use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
20use crate::error::{DecodeError, EncodeError};
21use crate::nbt::{AnonNbt, RawNbt};
22use crate::packet::{Direction, PacketSet, RawPacket, State};
23#[cfg(feature = "testgen")]
24use crate::testgen::{Gen, Generate};
25use crate::types::{BlockPos, ByteString, Holder, HolderSet, LpVec3, PositionLayout, Uuid};
26use bytes::{BufMut, Bytes, BytesMut};
27
28#[cfg(any(
29 feature = "v1_8",
30 feature = "v1_12_2",
31 feature = "v1_16_5",
32 feature = "v26_1",
33 feature = "v26_2"
34))]
35#[derive(Debug, Clone, PartialEq)]
37pub struct Disconnect<const V: i32> {
38 pub reason: ByteString,
40}
41#[cfg(any(
42 feature = "v1_8",
43 feature = "v1_12_2",
44 feature = "v1_16_5",
45 feature = "v26_1",
46 feature = "v26_2"
47))]
48impl<const V: i32> Decode for Disconnect<V> {
49 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
50 Ok({
51 let v1 = r.read_string()?;
52 Self { reason: v1 }
53 })
54 }
55}
56#[cfg(any(
57 feature = "v1_8",
58 feature = "v1_12_2",
59 feature = "v1_16_5",
60 feature = "v26_1",
61 feature = "v26_2"
62))]
63impl<const V: i32> Encode for Disconnect<V> {
64 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
65 w.put_string(&(*self).reason)?;
66 Ok(())
67 }
68}
69#[cfg(any(
70 feature = "v1_8",
71 feature = "v1_12_2",
72 feature = "v1_16_5",
73 feature = "v26_1",
74 feature = "v26_2"
75))]
76#[cfg(feature = "testgen")]
77impl<const V: i32> Generate for Disconnect<V> {
78 fn generate(g: &mut Gen) -> Self {
79 {
80 let v1 = g.string();
81 Self { reason: v1 }
82 }
83 }
84}
85
86#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
87#[derive(Debug, Clone, PartialEq)]
89pub struct EncryptionBegin<const V: i32> {
90 pub server_id: ByteString,
92 pub public_key: Bytes,
94 pub verify_token: Bytes,
96}
97#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
98impl<const V: i32> Decode for EncryptionBegin<V> {
99 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
100 Ok({
101 let v1 = r.read_string()?;
102 let v2 = r.read_byte_array()?;
103 let v3 = r.read_byte_array()?;
104 Self {
105 server_id: v1,
106 public_key: v2,
107 verify_token: v3,
108 }
109 })
110 }
111}
112#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
113impl<const V: i32> Encode for EncryptionBegin<V> {
114 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
115 w.put_string(&(*self).server_id)?;
116 w.put_byte_array(&(*self).public_key)?;
117 w.put_byte_array(&(*self).verify_token)?;
118 Ok(())
119 }
120}
121#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
122#[cfg(feature = "testgen")]
123impl<const V: i32> Generate for EncryptionBegin<V> {
124 fn generate(g: &mut Gen) -> Self {
125 {
126 let v1 = g.string();
127 let v2 = g.bytes();
128 let v3 = g.bytes();
129 Self {
130 server_id: v1,
131 public_key: v2,
132 verify_token: v3,
133 }
134 }
135 }
136}
137
138#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
139#[derive(Debug, Clone, PartialEq)]
141pub struct Success<const V: i32> {
142 pub uuid: ByteString,
144 pub username: ByteString,
146}
147#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
148impl<const V: i32> Decode for Success<V> {
149 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
150 Ok({
151 let v1 = r.read_string()?;
152 let v2 = r.read_string()?;
153 Self {
154 uuid: v1,
155 username: v2,
156 }
157 })
158 }
159}
160#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
161impl<const V: i32> Encode for Success<V> {
162 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
163 w.put_string(&(*self).uuid)?;
164 w.put_string(&(*self).username)?;
165 Ok(())
166 }
167}
168#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
169#[cfg(feature = "testgen")]
170impl<const V: i32> Generate for Success<V> {
171 fn generate(g: &mut Gen) -> Self {
172 {
173 let v1 = g.string();
174 let v2 = g.string();
175 Self {
176 uuid: v1,
177 username: v2,
178 }
179 }
180 }
181}
182
183#[cfg(any(
184 feature = "v1_8",
185 feature = "v1_12_2",
186 feature = "v1_16_5",
187 feature = "v26_1",
188 feature = "v26_2"
189))]
190#[derive(Debug, Clone, PartialEq)]
192pub struct Compress<const V: i32> {
193 pub threshold: i32,
195}
196#[cfg(any(
197 feature = "v1_8",
198 feature = "v1_12_2",
199 feature = "v1_16_5",
200 feature = "v26_1",
201 feature = "v26_2"
202))]
203impl<const V: i32> Decode for Compress<V> {
204 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
205 Ok({
206 let v1 = r.read_varint()?;
207 Self { threshold: v1 }
208 })
209 }
210}
211#[cfg(any(
212 feature = "v1_8",
213 feature = "v1_12_2",
214 feature = "v1_16_5",
215 feature = "v26_1",
216 feature = "v26_2"
217))]
218impl<const V: i32> Encode for Compress<V> {
219 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
220 w.put_varint((*self).threshold);
221 Ok(())
222 }
223}
224#[cfg(any(
225 feature = "v1_8",
226 feature = "v1_12_2",
227 feature = "v1_16_5",
228 feature = "v26_1",
229 feature = "v26_2"
230))]
231#[cfg(feature = "testgen")]
232impl<const V: i32> Generate for Compress<V> {
233 fn generate(g: &mut Gen) -> Self {
234 {
235 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
236 Self { threshold: v1 }
237 }
238 }
239}