wolfrpg_map_parser/command/
picture_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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};
use crate::command::picture_command::erase::Erase;
use crate::command::picture_command::show::Show;

pub mod show;
pub mod options;
pub mod display_type;
pub mod blending_method;
pub mod anchor;
pub mod zoom;
pub mod colors;
pub mod erase;

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq)]
pub enum PictureCommand {
    Show(Show),
    Erase(Erase),
}

impl PictureCommand {
    pub(crate) fn parse_show_base(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Show) = Show::parse_base(bytes);

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

    pub(crate) fn parse_show_colors(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Show) = Show::parse_colors(bytes);

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

    pub(crate) fn parse_show_delay(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Show) = Show::parse_delay(bytes);

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

    pub(crate) fn parse_show_range(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Show) = Show::parse_range(bytes);

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

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

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

    pub(crate) fn parse_show_zoom(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Show) = Show::parse_zoom(bytes);

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

    pub(crate) fn parse_show_free_transform(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Show) = Show::parse_free_transform(bytes);

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

    pub(crate) fn parse_erase_delay_reset(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Erase) = Erase::parse_delay_reset(bytes);

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

    pub(crate) fn parse_erase_base(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Erase) = Erase::parse_base(bytes);

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

    pub(crate) fn parse_erase_delay(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Erase) = Erase::parse_delay(bytes);

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

    pub(crate) fn parse_erase_range(bytes: &[u8]) -> (usize, Self) {
        let (bytes_read, command): (usize, Erase) = Erase::parse_range(bytes);

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