Skip to main content

nurtex_protocol/types/
particle_status.rs

1use nurtex_codec::{Buffer, VarInt};
2
3/// Статус видимости партиклов
4#[derive(Debug, Clone, PartialEq, PartialOrd)]
5pub enum ParticleStatus {
6  All,
7  Decreased,
8  Minimal,
9}
10
11impl Buffer for ParticleStatus {
12  fn read_buf(buffer: &mut std::io::Cursor<&[u8]>) -> Option<Self> {
13    let id = i32::read_varint(buffer)?;
14
15    Some(match id {
16      0 => Self::All,
17      1 => Self::Decreased,
18      2 => Self::Minimal,
19      _ => return None,
20    })
21  }
22
23  fn write_buf(&self, buffer: &mut impl std::io::Write) -> std::io::Result<()> {
24    let id = match self {
25      Self::All => 0,
26      Self::Decreased => 1,
27      Self::Minimal => 2,
28    };
29
30    id.write_varint(buffer)
31  }
32}