wolfrpg_map_parser/command/
input_key_command.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::command::input_key_command::automatic_input::AutomaticInput;
4use crate::command::input_key_command::input_key::InputKey;
5use crate::command::input_key_command::input_toggle::InputToggle;
6
7pub mod input_key;
8pub mod automatic_input;
9pub mod input_toggle;
10
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12#[derive(PartialEq, Clone)]
13pub enum InputKeyCommand {
14 InputKey(InputKey),
15 AutomaticInput(AutomaticInput),
16 InputToggle(InputToggle)
17}
18
19impl InputKeyCommand {
20 pub(crate) fn parse_input_key_base(bytes: &[u8]) -> (usize, Self) {
21 let (bytes_read, command): (usize, InputKey) = InputKey::parse_base(bytes);
22
23 (bytes_read, Self::InputKey(command))
24 }
25
26 pub(crate) fn parse_input_key_keyboard_or_pad(bytes: &[u8]) -> (usize, Self) {
27 let (bytes_read, command): (usize, InputKey) = InputKey::parse_keyboard_or_pad(bytes);
28
29 (bytes_read, Self::InputKey(command))
30 }
31
32 pub(crate) fn parse_automatic_input_base(bytes: &[u8]) -> (usize, Self) {
33 let (bytes_read, command): (usize, AutomaticInput) = AutomaticInput::parse_base(bytes);
34
35 (bytes_read, Self::AutomaticInput(command))
36 }
37
38 pub(crate) fn parse_automatic_input_keyboard(bytes: &[u8]) -> (usize, Self) {
39 let (bytes_read, command): (usize, AutomaticInput) = AutomaticInput::parse_keyboard(bytes);
40
41 (bytes_read, Self::AutomaticInput(command))
42 }
43
44 pub(crate) fn parse_input_toggle(bytes: &[u8]) -> (usize, Self) {
45 let (bytes_read, command): (usize, InputToggle) = InputToggle::parse(bytes);
46
47 (bytes_read, Self::InputToggle(command))
48 }
49}