use serde::{Deserialize, Serialize};
use crate::common::{CRCTreeNode, FileMetaPair};
pub const MAGIC_START: [u8; 7] = [b'n', b'd', b'p', b'k', 0x01, 0xff, 0x00];
pub const MAGIC_SEP: [u8; 5] = [0xff, 0x00, 0x00, 0xdd, 0x00];
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct PKTrailer {
pub file_list_base_addr: u32,
pub num_compressed: u32,
}
pub type PKEntry = CRCTreeNode<PKEntryData>;
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct PKEntryData {
pub meta: FileMetaPair,
pub file_data_addr: u32,
pub is_compressed: u32,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_size() {
assert_eq!(std::mem::size_of::<PKEntry>(), 60);
}
#[test]
fn test() {
let h: PKTrailer = bincode::deserialize(&[1, 0, 0, 0, 2, 0, 0, 0]).unwrap();
assert_eq!(h.file_list_base_addr, 1);
assert_eq!(h.num_compressed, 2);
}
}