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

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

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

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

        offset += 3; // Command end signature

        (offset, Self {
            chipset
        })
    }

    pub fn chipset(&self) -> u32 {
        self.chipset
    }
    
    pub fn chipset_mut(&mut self) -> &mut u32 {
        &mut self.chipset
    }
}