2024-01-16 03:09:34 +00:00
|
|
|
//file format "sniff"
|
|
|
|
|
|
|
|
pub enum Error{
|
|
|
|
InvalidMagic,
|
|
|
|
InvalidVersion,
|
2024-01-16 03:30:26 +00:00
|
|
|
UnexpectedEOF,
|
2024-01-16 03:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
pub enum Magic{
|
|
|
|
Map, //"SNFM"
|
|
|
|
Bot, //"SNFB"
|
|
|
|
Demo, //"SNFD"
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Header{
|
|
|
|
/// Type of file
|
|
|
|
magic:Magic,
|
|
|
|
/// 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 struct BlockLayout{
|
|
|
|
count:u64,
|
|
|
|
location:Vec<u64>,
|
|
|
|
}
|
2024-01-17 04:07:11 +00:00
|
|
|
|
|
|
|
pub struct File{
|
|
|
|
//???
|
|
|
|
}
|