mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 15:25:38 +00:00
Update to rust HEAD
This commit is contained in:
parent
5bfc73e36b
commit
4fc124de9b
@ -41,6 +41,7 @@ impl Deserializable for Animal {
|
|||||||
enum Error {
|
enum Error {
|
||||||
EndOfStream,
|
EndOfStream,
|
||||||
SyntaxError,
|
SyntaxError,
|
||||||
|
OtherError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -48,7 +49,7 @@ enum Error {
|
|||||||
mod decoder {
|
mod decoder {
|
||||||
use serialize::Decoder;
|
use serialize::Decoder;
|
||||||
|
|
||||||
use super::{Animal, Dog, Frog, Error, SyntaxError};
|
use super::{Animal, Dog, Frog, Error, SyntaxError, OtherError};
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
AnimalState(Animal),
|
AnimalState(Animal),
|
||||||
@ -73,6 +74,10 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Decoder<Error> for AnimalDecoder {
|
impl Decoder<Error> for AnimalDecoder {
|
||||||
|
fn error(&mut self, msg: &str) -> Error {
|
||||||
|
OtherError(msg.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
// Primitive types:
|
// Primitive types:
|
||||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||||
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||||
|
@ -12,6 +12,7 @@ use de::{Deserializer, Deserializable};
|
|||||||
enum Error {
|
enum Error {
|
||||||
EndOfStream,
|
EndOfStream,
|
||||||
SyntaxError,
|
SyntaxError,
|
||||||
|
OtherError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -21,7 +22,7 @@ mod decoder {
|
|||||||
use std::collections::hashmap::MoveEntries;
|
use std::collections::hashmap::MoveEntries;
|
||||||
use serialize;
|
use serialize;
|
||||||
|
|
||||||
use super::{Error, EndOfStream, SyntaxError};
|
use super::{Error, EndOfStream, SyntaxError, OtherError};
|
||||||
|
|
||||||
enum Value {
|
enum Value {
|
||||||
StringValue(String),
|
StringValue(String),
|
||||||
@ -46,6 +47,10 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl serialize::Decoder<Error> for IntDecoder {
|
impl serialize::Decoder<Error> for IntDecoder {
|
||||||
|
fn error(&mut self, msg: &str) -> Error {
|
||||||
|
OtherError(msg.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
// Primitive types:
|
// Primitive types:
|
||||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||||
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||||
|
@ -120,13 +120,14 @@ impl Deserializable for Outer {
|
|||||||
enum Error {
|
enum Error {
|
||||||
EndOfStream,
|
EndOfStream,
|
||||||
SyntaxError,
|
SyntaxError,
|
||||||
|
OtherError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
mod decoder {
|
mod decoder {
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use serialize::Decoder;
|
use serialize::Decoder;
|
||||||
|
|
||||||
use super::{Outer, Inner, Error, SyntaxError};
|
use super::{Outer, Inner, Error, SyntaxError, OtherError};
|
||||||
|
|
||||||
#[deriving(Show)]
|
#[deriving(Show)]
|
||||||
enum State {
|
enum State {
|
||||||
@ -157,6 +158,10 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Decoder<Error> for OuterDecoder {
|
impl Decoder<Error> for OuterDecoder {
|
||||||
|
fn error(&mut self, msg: &str) -> Error {
|
||||||
|
OtherError(msg.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
// Primitive types:
|
// Primitive types:
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_nil(&mut self) -> Result<(), Error> {
|
fn read_nil(&mut self) -> Result<(), Error> {
|
||||||
|
@ -11,6 +11,7 @@ use de::{Deserializer, Deserializable};
|
|||||||
enum Error {
|
enum Error {
|
||||||
EndOfStream,
|
EndOfStream,
|
||||||
SyntaxError,
|
SyntaxError,
|
||||||
|
OtherError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -19,7 +20,7 @@ mod decoder {
|
|||||||
use std::vec;
|
use std::vec;
|
||||||
use serialize;
|
use serialize;
|
||||||
|
|
||||||
use super::{Error, EndOfStream, SyntaxError};
|
use super::{Error, EndOfStream, SyntaxError, OtherError};
|
||||||
|
|
||||||
pub struct IntDecoder {
|
pub struct IntDecoder {
|
||||||
len: uint,
|
len: uint,
|
||||||
@ -37,6 +38,10 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl serialize::Decoder<Error> for IntDecoder {
|
impl serialize::Decoder<Error> for IntDecoder {
|
||||||
|
fn error(&mut self, msg: &str) -> Error {
|
||||||
|
OtherError(msg.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
// Primitive types:
|
// Primitive types:
|
||||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||||
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||||
@ -138,6 +143,10 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl serialize::Decoder<Error> for U8Decoder {
|
impl serialize::Decoder<Error> for U8Decoder {
|
||||||
|
fn error(&mut self, msg: &str) -> Error {
|
||||||
|
OtherError(msg.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
// Primitive types:
|
// Primitive types:
|
||||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||||
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
fn read_uint(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user