This commit is contained in:
Quaternions 2024-01-15 19:30:26 -08:00
parent a9504a192b
commit fc1c9e843f
2 changed files with 21 additions and 29 deletions

View File

@ -1,24 +1,9 @@
//file format "sniff"
pub enum Error{
Header(HeaderError),
Map(crate::map::Error),
Bot(crate::bot::Error),
Demo(crate::demo::Error),
}
pub enum MissingData{
NeedExactly(usize),//missing exactly this many bytes
NeedAtLeast(usize),//missing at least this many bytes
}
pub enum HeaderError{
InvalidMagic,
InvalidVersion,
UnexpectedEOF{
eof:usize,
missing_data:MissingData,
},//file ends in the middle of the header
UnexpectedEOF,
}
/* spec
@ -53,7 +38,6 @@ pub enum Magic{
Map, //"SNFM"
Bot, //"SNFB"
Demo, //"SNFD"
PlaylistDemo,
}
pub struct Header{
@ -71,9 +55,3 @@ pub struct BlockLayout{
count:u64,
location:Vec<u64>,
}
pub enum SNF{
Map(crate::map::Map),
Bot(crate::bot::Bot),
Demo(crate::demo::Demo),
}

View File

@ -1,12 +1,26 @@
use std::io::Read;
mod file;
mod map;
mod bot;
mod demo;
pub mod file;
pub mod map;
pub mod bot;
pub mod demo;
pub fn read<R:Read>(input:R)->Result<crate::file::SNF,crate::file::Error>{
Err(file::Error::Header(file::HeaderError::InvalidMagic))
pub enum Error{
Header(file::Error),
Map(map::Error),
Bot(bot::Error),
Demo(demo::Error),
}
pub enum SNF{
Map(map::Map),
Bot(bot::Bot),
Demo(demo::Demo),
}
pub fn read<R:Read>(input:R)->Result<SNF,Error>{
//let header:file::Header=input.read()?;
Err(Error::Header(file::Error::InvalidMagic))
}
#[cfg(test)]