nurtex_protocol/types/
intention.rs1use nurtex_codec::Buffer;
2use nurtex_codec::types::variable::VarI32;
3
4#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
5pub enum ClientIntention {
6 Status,
7 Login,
8}
9
10impl Buffer for ClientIntention {
11 fn read_buf(buffer: &mut std::io::Cursor<&[u8]>) -> Option<Self> {
12 let id = i32::read_var(buffer)?;
13
14 Some(match id {
15 1 => Self::Status,
16 2 => Self::Login,
17 _ => return None,
18 })
19 }
20
21 fn write_buf(&self, buffer: &mut impl std::io::Write) -> std::io::Result<()> {
22 let id = match self {
23 Self::Status => 1,
24 Self::Login => 2,
25 };
26
27 id.write_var(buffer)
28 }
29}