Add json deserializer
This commit is contained in:
parent
7b6ff6ac13
commit
b211862602
4 changed files with 34 additions and 0 deletions
|
@ -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
1
src/storage/json/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod parser;
|
30
src/storage/json/parser.rs
Normal file
30
src/storage/json/parser.rs
Normal 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> {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -7,3 +7,5 @@ pub use runtime::Runtime;
|
||||||
pub mod file;
|
pub mod file;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
|
|
||||||
|
pub mod json;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue