Skip to main content

steel_protocol/packets/login/
c_hello.rs

1use steel_macros::{ClientPacket, WriteTo};
2use steel_registry::packets::login::C_HELLO;
3
4#[derive(ClientPacket, WriteTo, Clone, Debug)]
5#[packet_id(Login = C_HELLO)]
6pub struct CHello<'a> {
7    #[write(as = Prefixed(VarInt), bound = 20)]
8    pub server_id: String,
9    #[write(as = Prefixed(VarInt))]
10    pub public_key: &'a [u8],
11    #[write(as = Prefixed(VarInt))]
12    pub challenge: [u8; 4],
13    pub should_authenticate: bool,
14}
15
16impl<'a> CHello<'a> {
17    #[must_use]
18    pub const fn new(
19        server_id: String,
20        public_key: &'a [u8],
21        challenge: [u8; 4],
22        should_authenticate: bool,
23    ) -> Self {
24        Self {
25            server_id,
26            public_key,
27            challenge,
28            should_authenticate,
29        }
30    }
31}