Add json deserializer

This commit is contained in:
Matthias Beyer 2015-11-08 17:32:43 +01:00
parent 7b6ff6ac13
commit b211862602
4 changed files with 34 additions and 0 deletions

View file

@ -1,5 +1,6 @@
#[macro_use] extern crate clap; #[macro_use] extern crate clap;
#[macro_use] extern crate log; #[macro_use] extern crate log;
#[macro_use] extern crate serde_json;
extern crate config; extern crate config;
extern crate regex; extern crate regex;

1
src/storage/json/mod.rs Normal file
View file

@ -0,0 +1 @@
pub mod parser;

View file

@ -0,0 +1,30 @@
use serde_json::Value;
use super::parser;
struct JsonHeaderParser {
spec: &FileHeaderSpec,
}
impl FileHeaderParser for JsonHeaderParser {
fn new(spec: &FileHeaderSpec) -> JsonHeaderParser {
JsonHeaderParser {
spec: spec
}
}
fn read(&self, string: Option<String>)
-> Result<FileHeaderData, ParserError>
{
if let Ok(content) = data = serde_json::from_str(&string[..]) {
} else {
ParserError::short("Unknown JSON parser error", string.clone(), 0)
}
}
fn write(&self, data: &FileHeaderData) -> Result<String, ParserError> {
}
}

View file

@ -7,3 +7,5 @@ pub use runtime::Runtime;
pub mod file; pub mod file;
pub mod parser; pub mod parser;
pub mod json;