wolfrpg_map_parser/command/set_string_command/
input.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
use crate::byte_utils::as_u32_le;
#[cfg(feature = "serde")]
use serde::Serialize;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Input {
    max_length: u32
}

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

        let max_length: u32 = as_u32_le(&bytes[offset..offset + 4]);
        offset += 4;

        offset += 3; // Command end signature

        (offset, Self {
            max_length
        })
    }

    pub fn max_length(&self) -> u32 {
        self.max_length
    }

    pub fn max_length_mut(&mut self) -> &mut u32 {
        &mut self.max_length
    }
}