Initial version of json serialization working

This commit is contained in:
Erick Tryzelaar 2014-06-12 23:14:52 -07:00
parent 3cf15fb7f3
commit 7a536f22ef
2 changed files with 658 additions and 737 deletions

1311
json.rs

File diff suppressed because it is too large Load Diff

10
ser.rs
View File

@ -13,6 +13,7 @@ use std::hash::Hash;
#[deriving(Clone, PartialEq, Show)]
pub enum Token<'a> {
Null,
Bool(bool),
Int(int),
I8(i8),
@ -43,8 +44,6 @@ pub enum Token<'a> {
pub trait Serializer<E> {
fn serialize<'a>(&mut self, token: Token<'a>) -> Result<(), E>;
fn syntax_error<T>(&self) -> Result<T, E>;
}
//////////////////////////////////////////////////////////////////////////////
@ -171,8 +170,7 @@ macro_rules! impl_serialize_tuple {
> Serializable<E, S> for () {
#[inline]
fn serialize(&self, s: &mut S) -> Result<(), E> {
try!(s.serialize(TupleStart(0)));
s.serialize(End)
s.serialize(Null)
}
}
};
@ -315,10 +313,6 @@ mod tests {
Ok(())
}
fn syntax_error<T>(&self) -> Result<T, Error> {
Err(SyntaxError)
}
}
//////////////////////////////////////////////////////////////////////////////