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