wolfrpg_map_parser/command/picture_command/erase/
delay.rs

1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::byte_utils::as_u32_le;
4use crate::command::picture_command::erase::base::Base;
5
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7#[derive(PartialEq, Clone)]
8pub struct Delay {
9    base_fields: Base,
10    delay: u32,
11}
12
13impl Delay {
14    pub(crate) fn parse(bytes: &[u8]) -> (usize, Self) {
15        let mut offset: usize = 0;
16
17        let (bytes_read, base_fields): (usize, Base)
18            = Base::parse(&bytes[offset..]);
19        offset += bytes_read;
20
21        let delay: u32 = as_u32_le(&bytes[offset..offset+4]);
22        offset += 4;
23
24        (offset, Self {
25            base_fields,
26            delay
27        })
28    }
29
30    pub fn process_time(&self) -> u32 {
31        self.base_fields.process_time()
32    }
33
34    pub fn process_time_mut(&mut self) -> &mut u32 {
35        self.base_fields.process_time_mut()
36    }
37
38    pub fn delay(&self) -> u32 {
39        self.delay
40    }
41
42    pub fn delay_mut(&mut self) -> &mut u32 {
43        &mut self.delay
44    }
45}