wolfrpg_map_parser/command/
common_event_command.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
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};
use crate::command::common_event_command::event::Event;

pub mod event;
pub mod argument_count;
pub mod options;

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq)]
pub enum CommonEventCommand {
    CallEvent(Event),
    ReserveEvent(Event)
}

impl CommonEventCommand {
    pub(crate) fn parse_call_event(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Event) = Event::parse(bytes);

        (bytes_read, Self::CallEvent(command))
    }

    pub(crate) fn parse_reserve_event(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Event) = Event::parse(bytes);

        (bytes_read, Self::ReserveEvent(command))
    }
}