core: +FileHeader::decode
This commit is contained in:
parent
a9d2508495
commit
7c06f7e045
|
@ -18,6 +18,24 @@ pub enum FileType {
|
|||
Text = 0x0000_0001,
|
||||
}
|
||||
|
||||
pub struct FileHeader {
|
||||
pub magic: [u8; 4],
|
||||
pub generator: u32,
|
||||
pub typ: u32,
|
||||
pub version: u32,
|
||||
}
|
||||
|
||||
impl FileHeader {
|
||||
pub fn decode(data: [u8; 16]) -> Self {
|
||||
Self {
|
||||
magic: data[0..4].try_into().unwrap(),
|
||||
generator: u32::from_be_bytes(data[4..8].try_into().unwrap()),
|
||||
typ: u32::from_be_bytes(data[8..12].try_into().unwrap()),
|
||||
version: u32::from_be_bytes(data[12..16].try_into().unwrap()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, IntEnum)]
|
||||
#[repr(u32)]
|
||||
#[rustfmt::skip]
|
||||
|
|
Loading…
Reference in a new issue