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))]
69#[derive(Debug, Clone, PartialEq)]
71pub struct EncryptionBegin<const V: i32> {
72 pub shared_secret: Bytes,
74 pub verify_token: Bytes,
76}
77#[cfg(any(
78 feature = "v1_8",
79 feature = "v1_12_2",
80 feature = "v1_16_5",
81 feature = "v26_1",
82 feature = "v26_2"
83))]
84impl<const V: i32> Decode for EncryptionBegin<V> {
85 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
86 Ok({
87 let v1 = r.read_byte_array()?;
88 let v2 = r.read_byte_array()?;
89 Self {
90 shared_secret: v1,
91 verify_token: v2,
92 }
93 })
94 }
95}
96#[cfg(any(
97 feature = "v1_8",
98 feature = "v1_12_2",
99 feature = "v1_16_5",
100 feature = "v26_1",
101 feature = "v26_2"
102))]
103impl<const V: i32> Encode for EncryptionBegin<V> {
104 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
105 w.put_byte_array(&(*self).shared_secret)?;
106 w.put_byte_array(&(*self).verify_token)?;
107 Ok(())
108 }
109}
110#[cfg(any(
111 feature = "v1_8",
112 feature = "v1_12_2",
113 feature = "v1_16_5",
114 feature = "v26_1",
115 feature = "v26_2"
116))]
117#[cfg(feature = "testgen")]
118impl<const V: i32> Generate for EncryptionBegin<V> {
119 fn generate(g: &mut Gen) -> Self {
120 {
121 let v1 = g.bytes();
122 let v2 = g.bytes();
123 Self {
124 shared_secret: v1,
125 verify_token: v2,
126 }
127 }
128 }
129}