wolfrpg_map_parser/command/input_key_command/input_key/
basic.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::command::input_key_command::input_key::basic_options::BasicOptions;
#[cfg(feature = "serde")]
use serde::Serialize;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Basic {
    options: BasicOptions
}

impl Basic {
    pub fn parse(bytes: &[u8]) -> (usize, Self) {
        let mut offset: usize = 0;

        let options: u8 = bytes[offset];
        let options: BasicOptions = BasicOptions::new(options);
        offset += 1;

        offset += 1; // input_type

        offset += 2; // Padding

        (offset, Self {
            options
        })
    }

    pub fn options(&self) -> &BasicOptions {
        &self.options
    }

    pub fn options_mut(&mut self) -> &mut BasicOptions {
        &mut self.options
    }
}