Move header types/traits outside own module

This commit is contained in:
Matthias Beyer 2015-10-28 19:21:22 +01:00
parent 647d5611c7
commit 380d58a3c0

View file

@ -86,36 +86,32 @@ pub mod file {
}
}
pub mod header {
pub enum FileHeaderSpec {
Null,
Bool,
Integer,
UInteger,
Float,
Text,
Key { name: String, value_type: Box<FileHeaderSpec> },
Array { allowed_types: Box<Vec<FileHeaderSpec>> },
}
pub enum FileHeaderSpec {
Null,
Bool,
Integer,
UInteger,
Float,
Text,
Key { name: String, value_type: Box<FileHeaderSpec> },
Array { allowed_types: Box<Vec<FileHeaderSpec>> },
}
pub enum FileHeaderData {
Null,
Bool(bool),
Integer(i64),
UInteger(u64),
Float(f64),
Text(String),
Key { name: String, value: Box<FileHeaderData> },
Array { values: Box<Vec<FileHeaderData>> },
}
pub trait FileHeaderParser : Sized {
fn new(spec: &FileHeaderSpec) -> Self;
fn read(&self, string: &String) -> Result<FileHeaderData, super::ParserError>;
fn write(&self, data: &FileHeaderData) -> Result<String, super::ParserError>;
}
pub enum FileHeaderData {
Null,
Bool(bool),
Integer(i64),
UInteger(u64),
Float(f64),
Text(String),
Key { name: String, value: Box<FileHeaderData> },
Array { values: Box<Vec<FileHeaderData>> },
}
pub trait FileHeaderParser : Sized {
fn new(spec: &FileHeaderSpec) -> Self;
fn read(&self, string: &String) -> Result<FileHeaderData, ParserError>;
fn write(&self, data: &FileHeaderData) -> Result<String, ParserError>;
}
pub trait FileData : Sized {