udpated serde to version 0.7.0

This commit is contained in:
debris
2016-02-27 13:14:58 +01:00
parent db9774fb62
commit 11de5b4923
10 changed files with 48 additions and 42 deletions

View File

@@ -9,19 +9,19 @@ build = "build.rs"
[lib]
[dependencies]
serde = "0.6.7"
serde_json = "0.6.0"
jsonrpc-core = "1.1"
jsonrpc-http-server = "2.0"
serde = "0.7.0"
serde_json = "0.7.0"
jsonrpc-core = "1.2"
jsonrpc-http-server = "2.1"
ethcore-util = { path = "../util" }
ethcore = { path = "../ethcore" }
ethsync = { path = "../sync" }
clippy = { version = "0.0.44", optional = true }
rustc-serialize = "0.3"
serde_macros = { version = "0.6.13", optional = true }
serde_macros = { version = "0.7.0", optional = true }
[build-dependencies]
serde_codegen = { version = "0.6.13", optional = true }
serde_codegen = { version = "0.7.0", optional = true }
syntex = "0.29.0"
[features]

View File

@@ -16,8 +16,8 @@
//! Ethcore rpc.
#![warn(missing_docs)]
#![cfg_attr(nightly, feature(custom_derive, custom_attribute, plugin))]
#![cfg_attr(nightly, plugin(serde_macros, clippy))]
#![cfg_attr(feature="nightly", feature(custom_derive, custom_attribute, plugin))]
#![cfg_attr(feature="nightly", plugin(serde_macros, clippy))]
extern crate rustc_serialize;
extern crate serde;

View File

@@ -30,7 +30,7 @@ pub enum BlockNumber {
impl Deserialize for BlockNumber {
fn deserialize<D>(deserializer: &mut D) -> Result<BlockNumber, D::Error>
where D: Deserializer {
deserializer.visit(BlockNumberVisitor)
deserializer.deserialize(BlockNumberVisitor)
}
}
@@ -44,8 +44,8 @@ impl Visitor for BlockNumberVisitor {
"latest" => Ok(BlockNumber::Latest),
"earliest" => Ok(BlockNumber::Earliest),
"pending" => Ok(BlockNumber::Pending),
_ if value.starts_with("0x") => u64::from_str_radix(&value[2..], 16).map(BlockNumber::Num).map_err(|_| Error::syntax("invalid block number")),
_ => value.parse::<u64>().map(BlockNumber::Num).map_err(|_| Error::syntax("invalid block number"))
_ if value.starts_with("0x") => u64::from_str_radix(&value[2..], 16).map(BlockNumber::Num).map_err(|_| Error::custom("invalid block number")),
_ => value.parse::<u64>().map(BlockNumber::Num).map_err(|_| Error::custom("invalid block number"))
}
}

View File

@@ -40,7 +40,7 @@ impl Serialize for Bytes {
where S: Serializer {
let mut serialized = "0x".to_owned();
serialized.push_str(self.0.to_hex().as_ref());
serializer.visit_str(serialized.as_ref())
serializer.serialize_str(serialized.as_ref())
}
}

View File

@@ -40,7 +40,7 @@ impl<T> Deserialize for VariadicValue<T> where T: Deserialize {
Deserialize::deserialize(&mut value::Deserializer::new(v.clone())).map(VariadicValue::Single)
.or_else(|_| Deserialize::deserialize(&mut value::Deserializer::new(v.clone())).map(VariadicValue::Multiple))
.map_err(|_| Error::syntax("")) // unreachable, but types must match
.map_err(|_| Error::custom("")) // unreachable, but types must match
}
}
@@ -48,6 +48,7 @@ pub type FilterAddress = VariadicValue<Address>;
pub type Topic = VariadicValue<H256>;
#[derive(Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Filter {
#[serde(rename="fromBlock")]
pub from_block: Option<BlockNumber>,

View File

@@ -30,7 +30,7 @@ impl Index {
impl Deserialize for Index {
fn deserialize<D>(deserializer: &mut D) -> Result<Index, D::Error>
where D: Deserializer {
deserializer.visit(IndexVisitor)
deserializer.deserialize(IndexVisitor)
}
}
@@ -41,8 +41,8 @@ impl Visitor for IndexVisitor {
fn visit_str<E>(&mut self, value: &str) -> Result<Self::Value, E> where E: Error {
match value {
_ if value.starts_with("0x") => usize::from_str_radix(&value[2..], 16).map(Index).map_err(|_| Error::syntax("invalid index")),
_ => value.parse::<usize>().map(Index).map_err(|_| Error::syntax("invalid index"))
_ if value.starts_with("0x") => usize::from_str_radix(&value[2..], 16).map(Index).map_err(|_| Error::custom("invalid index")),
_ => value.parse::<usize>().map(Index).map_err(|_| Error::custom("invalid index"))
}
}