diff --git a/src/module/mod.rs b/src/module/mod.rs index 9fd8b88a..59a10317 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -54,3 +54,57 @@ pub trait Module { } + +pub mod file { + + pub struct ParserError { + summary: String, + parsertext: String, + index: i32, + explanation: Option, + } + + pub mod header { + + pub enum FileHeaderSpec { + Null, + Bool, + Integer, + UInteger, + Float, + Text, + Key { name: String, value_type: Box }, + Array { allowed_types: Box> }, + } + + pub enum FileHeaderData { + Null, + Bool(bool), + Integer(i64), + UInteger(u64), + Float(f64), + Text(String), + Key { name: String, value: Box }, + Array { values: Box> }, + } + + pub trait FileHeaderParser { + fn new(spec: &FileHeaderSpec) -> Self; + fn read(&self, string: &String) -> Result; + fn write(&self, data: &FileHeaderData) -> Result; + } + + } + + pub trait FileData { + fn get_fulltext(&self) -> String; + fn get_abbrev(&self) -> String; + } + + pub trait FileParser { + fn new(header_parser: &header::FileHeaderParser) -> FileParser; + fn read(&self, string: String) -> (header::FileHeaderData, FileData); + fn write(&self, hdr: &header::FileHeaderData, data: &FileData) -> Result; + } + +}