ghast_protocol/generated/defs/p775/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(feature = "v26_1")]
29#[derive(Debug, Clone, PartialEq)]
31pub struct EncryptionBegin<const V: i32> {
32 pub server_id: ByteString,
34 pub public_key: Bytes,
36 pub verify_token: Bytes,
38 pub should_authenticate: bool,
40}
41#[cfg(feature = "v26_1")]
42impl<const V: i32> Decode for EncryptionBegin<V> {
43 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
44 Ok({
45 let v1 = r.read_string()?;
46 let v2 = r.read_byte_array()?;
47 let v3 = r.read_byte_array()?;
48 let v4 = r.read_bool()?;
49 Self {
50 server_id: v1,
51 public_key: v2,
52 verify_token: v3,
53 should_authenticate: v4,
54 }
55 })
56 }
57}
58#[cfg(feature = "v26_1")]
59impl<const V: i32> Encode for EncryptionBegin<V> {
60 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
61 w.put_string(&(*self).server_id)?;
62 w.put_byte_array(&(*self).public_key)?;
63 w.put_byte_array(&(*self).verify_token)?;
64 w.put_bool((*self).should_authenticate);
65 Ok(())
66 }
67}
68#[cfg(feature = "v26_1")]
69#[cfg(feature = "testgen")]
70impl<const V: i32> Generate for EncryptionBegin<V> {
71 fn generate(g: &mut Gen) -> Self {
72 {
73 let v1 = g.string();
74 let v2 = g.bytes();
75 let v3 = g.bytes();
76 let v4 = g.bool();
77 Self {
78 server_id: v1,
79 public_key: v2,
80 verify_token: v3,
81 should_authenticate: v4,
82 }
83 }
84 }
85}
86
87#[cfg(feature = "v26_1")]
88#[derive(Debug, Clone, PartialEq)]
90pub struct SuccessProperties {
91 pub name: ByteString,
93 pub value: ByteString,
95 pub signature: Option<ByteString>,
97}
98
99#[cfg(feature = "v26_1")]
100#[derive(Debug, Clone, PartialEq)]
102pub struct Success<const V: i32> {
103 pub uuid: Uuid,
105 pub username: ByteString,
107 pub properties: Vec<crate::defs::p775::login::clientbound::SuccessProperties>,
109}
110#[cfg(feature = "v26_1")]
111impl<const V: i32> Decode for Success<V> {
112 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
113 Ok({
114 let v1 = r.read_uuid()?;
115 let v2 = r.read_string()?;
116 let v3 = {
117 let v4 = {
118 let c = r.read_varint()?;
119 r.check_count(i64::from(c), 3)?
120 };
121 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
122 for _ in 0..v4 {
123 v5.push({
124 let v6 = r.read_string()?;
125 let v7 = r.read_string()?;
126 let v8 = if r.read_bool()? {
127 Some(r.read_string()?)
128 } else {
129 None
130 };
131 crate::defs::p775::login::clientbound::SuccessProperties {
132 name: v6,
133 value: v7,
134 signature: v8,
135 }
136 });
137 }
138 v5
139 };
140 Self {
141 uuid: v1,
142 username: v2,
143 properties: v3,
144 }
145 })
146 }
147}
148#[cfg(feature = "v26_1")]
149impl<const V: i32> Encode for Success<V> {
150 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
151 w.put_uuid(&(*self).uuid);
152 w.put_string(&(*self).username)?;
153 w.put_len_varint((*self).properties.len())?;
154 for v1 in (*self).properties.iter() {
155 w.put_string(&(*v1).name)?;
156 w.put_string(&(*v1).value)?;
157 match &(*v1).signature {
158 Some(v2) => {
159 w.put_u8(1);
160 w.put_string(&(*v2))?;
161 }
162 None => w.put_u8(0),
163 }
164 }
165 Ok(())
166 }
167}
168#[cfg(feature = "v26_1")]
169#[cfg(feature = "testgen")]
170impl<const V: i32> Generate for Success<V> {
171 fn generate(g: &mut Gen) -> Self {
172 {
173 let v1 = g.uuid();
174 let v2 = g.string();
175 let v3 = {
176 let v4 = g.count();
177 let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
178 for _ in 0..v4 {
179 v5.push({
180 let v6 = g.string();
181 let v7 = g.string();
182 let v8 = if g.bool() { Some(g.string()) } else { None };
183 crate::defs::p775::login::clientbound::SuccessProperties {
184 name: v6,
185 value: v7,
186 signature: v8,
187 }
188 });
189 }
190 v5
191 };
192 Self {
193 uuid: v1,
194 username: v2,
195 properties: v3,
196 }
197 }
198 }
199}
200
201#[cfg(feature = "v26_1")]
202#[derive(Debug, Clone, PartialEq)]
204pub struct CookieRequest<const V: i32> {
205 pub cookie: ByteString,
207}
208#[cfg(feature = "v26_1")]
209impl<const V: i32> Decode for CookieRequest<V> {
210 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
211 Ok({
212 let v1 = r.read_string()?;
213 Self { cookie: v1 }
214 })
215 }
216}
217#[cfg(feature = "v26_1")]
218impl<const V: i32> Encode for CookieRequest<V> {
219 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
220 w.put_string(&(*self).cookie)?;
221 Ok(())
222 }
223}
224#[cfg(feature = "v26_1")]
225#[cfg(feature = "testgen")]
226impl<const V: i32> Generate for CookieRequest<V> {
227 fn generate(g: &mut Gen) -> Self {
228 {
229 let v1 = g.string();
230 Self { cookie: v1 }
231 }
232 }
233}