wolfrpg_map_parser/command/set_string_command/
state.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::command::set_string_command::base::Base;
4use crate::command::set_string_command::dynamic::Dynamic;
5use crate::command::set_string_command::input::Input;
6
7#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8#[derive(PartialEq, Clone)]
9pub enum State {
10 Base(Base),
11 Dynamic(Dynamic),
12 Input(Input),
13}
14
15impl State {
16 pub(crate) fn parse_base(bytes: &[u8]) -> (usize, Self) {
17 let (bytes_read, command): (usize, Base) = Base::parse(bytes);
18
19 (bytes_read, Self::Base(command))
20 }
21
22 pub(crate) fn parse_dynamic(bytes: &[u8]) -> (usize, Self) {
23 let (bytes_read, command): (usize, Dynamic) = Dynamic::parse(bytes);
24
25 (bytes_read, Self::Dynamic(command))
26 }
27
28 pub(crate) fn parse_input(bytes: &[u8]) -> (usize, Self) {
29 let (bytes_read, command): (usize, Input) = Input::parse(bytes);
30
31 (bytes_read, Self::Input(command))
32 }
33}