ghast_protocol/generated/defs/p47/login/
serverbound.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(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
29#[derive(Debug, Clone, PartialEq)]
31pub struct LoginStart<const V: i32> {
32 pub username: ByteString,
34}
35#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
36impl<const V: i32> Decode for LoginStart<V> {
37 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
38 Ok({
39 let v1 = r.read_string()?;
40 Self { username: v1 }
41 })
42 }
43}
44#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
45impl<const V: i32> Encode for LoginStart<V> {
46 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
47 w.put_string(&(*self).username)?;
48 Ok(())
49 }
50}
51#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
52#[cfg(feature = "testgen")]
53impl<const V: i32> Generate for LoginStart<V> {
54 fn generate(g: &mut Gen) -> Self {
55 {
56 let v1 = g.string();
57 Self { username: v1 }
58 }
59 }
60}
61
62#[cfg(any(
63 feature = "v1_8",
64 feature = "v1_12_2",
65 feature = "v1_16_5",
66 feature = "v26_1",
67 feature = "v26_2",
68 feature = "v26_3"
69))]
70#[derive(Debug, Clone, PartialEq)]
72pub struct EncryptionBegin<const V: i32> {
73 pub shared_secret: Bytes,
75 pub verify_token: Bytes,
77}
78#[cfg(any(
79 feature = "v1_8",
80 feature = "v1_12_2",
81 feature = "v1_16_5",
82 feature = "v26_1",
83 feature = "v26_2",
84 feature = "v26_3"
85))]
86impl<const V: i32> Decode for EncryptionBegin<V> {
87 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
88 Ok({
89 let v1 = r.read_byte_array()?;
90 let v2 = r.read_byte_array()?;
91 Self {
92 shared_secret: v1,
93 verify_token: v2,
94 }
95 })
96 }
97}
98#[cfg(any(
99 feature = "v1_8",
100 feature = "v1_12_2",
101 feature = "v1_16_5",
102 feature = "v26_1",
103 feature = "v26_2",
104 feature = "v26_3"
105))]
106impl<const V: i32> Encode for EncryptionBegin<V> {
107 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
108 w.put_byte_array(&(*self).shared_secret)?;
109 w.put_byte_array(&(*self).verify_token)?;
110 Ok(())
111 }
112}
113#[cfg(any(
114 feature = "v1_8",
115 feature = "v1_12_2",
116 feature = "v1_16_5",
117 feature = "v26_1",
118 feature = "v26_2",
119 feature = "v26_3"
120))]
121#[cfg(feature = "testgen")]
122impl<const V: i32> Generate for EncryptionBegin<V> {
123 fn generate(g: &mut Gen) -> Self {
124 {
125 let v1 = g.bytes();
126 let v2 = g.bytes();
127 Self {
128 shared_secret: v1,
129 verify_token: v2,
130 }
131 }
132 }
133}