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" //file format "sniff"
pub enum Error{ 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, InvalidMagic,
InvalidVersion, InvalidVersion,
UnexpectedEOF{ UnexpectedEOF,
eof:usize,
missing_data:MissingData,
},//file ends in the middle of the header
} }
/* spec /* spec
@ -53,7 +38,6 @@ pub enum Magic{
Map, //"SNFM" Map, //"SNFM"
Bot, //"SNFB" Bot, //"SNFB"
Demo, //"SNFD" Demo, //"SNFD"
PlaylistDemo,
} }
pub struct Header{ pub struct Header{
@ -71,9 +55,3 @@ pub struct BlockLayout{
count:u64, count:u64,
location:Vec<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; use std::io::Read;
mod file; pub mod file;
mod map; pub mod map;
mod bot; pub mod bot;
mod demo; pub mod demo;
pub fn read<R:Read>(input:R)->Result<crate::file::SNF,crate::file::Error>{ pub enum Error{
Err(file::Error::Header(file::HeaderError::InvalidMagic)) 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)] #[cfg(test)]