Merge branch 'debug'

This commit is contained in:
Matthias Beyer 2015-12-28 21:55:08 +01:00
commit 248b5c7574
2 changed files with 32 additions and 1 deletions

View file

@ -1,5 +1,7 @@
use std::collections::HashMap;
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::fmt;
use serde_json::{Value, from_str};
use serde_json::error::Result as R;
@ -25,6 +27,24 @@ impl JsonHeaderParser {
}
impl Display for JsonHeaderParser {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "JsonHeaderParser");
Ok(())
}
}
impl Debug for JsonHeaderParser {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "JsonHeaderParser, Spec: {:?}", self.spec);
Ok(())
}
}
impl FileHeaderParser for JsonHeaderParser {
fn read(&self, string: Option<String>)

View file

@ -83,7 +83,7 @@ impl Display for ParserError {
}
pub trait FileHeaderParser : Sized {
pub trait FileHeaderParser : Sized + Debug + Display {
fn read(&self, string: Option<String>) -> Result<FileHeaderData, ParserError>;
fn write(&self, data: &FileHeaderData) -> Result<String, ParserError>;
}
@ -164,3 +164,14 @@ impl<HP: FileHeaderParser> Parser<HP> {
}
impl<HP> Debug for Parser<HP>
where HP: FileHeaderParser
{
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "Parser<{:?}>", self.headerp);
Ok(())
}
}