Initial version of json serialization working
This commit is contained in:
parent
3cf15fb7f3
commit
7a536f22ef
10
ser.rs
10
ser.rs
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user