//file format "sniff" pub enum Error{ InvalidMagic, InvalidVersion, UnexpectedEOF, } /* spec //begin global header //global metadata (32 bytes) b"SNFB" u32 format_version u64 priming_bytes //how many bytes of the file must be read to guarantee all of the expected //format-specific metadata is available to facilitate streaming the remaining contents //used by the database to guarantee that it serves at least the bare minimum u128 resource_uuid //identifies the file from anywhere for any other file //global block layout (variable size) u64 num_blocks for block_id in 0..num_blocks{ u64 first_byte } //end global header //begin blocks //each block is compressed with zstd or gz or something */ #[derive(Clone,Copy)] pub(crate) enum FourCC{ Map, Bot, Demo, } struct Header{ /// Type of file fourcc:FourCC, /// Type version version:u32, /// Minimum data required to know the location of all streamable resources for this specific file priming:u64, /// uuid for this file resource:u128, } pub(crate) struct BlockLayout{ count:u64, location:Vec, } pub(crate) struct File{ header:Header, block_layout:BlockLayout, //reference to the data } impl File{ pub(crate) fn new(input:R)->Result{ Self{ header:input.read_le()?, block_layout:input.read_le()?, } } pub(crate) fn read_block(&mut self,block_id:u64)->Result,Error>{ Err(Error::UnexpectedEOF) } pub(crate) fn fourcc(&self)->FourCC{ self.header.fourcc } }