diff --git a/Cargo.lock b/Cargo.lock index 5f72c8d2..376d6590 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,7 +152,7 @@ dependencies = [ "bitcrypto 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitives 0.1.0", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serialization 0.1.0", "serialization_derive 0.1.0", ] @@ -522,7 +522,7 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitives 0.1.0", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -824,7 +824,7 @@ dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -866,7 +866,7 @@ dependencies = [ "bigint 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1008,7 +1008,7 @@ dependencies = [ "network 0.1.0", "p2p 0.1.0", "primitives 0.1.0", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "script 0.1.0", "serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1033,6 +1033,11 @@ dependencies = [ "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-hex" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rustc-serialize" version = "0.3.24" @@ -1178,7 +1183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "smallvec" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1601,6 +1606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb)" = "" "checksum rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)" = "" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" +"checksum rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b03280c2813907a030785570c577fb27d3deec8da4c18566751ade94de0ace" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9743a7670d88d5d52950408ecdb7c71d8986251ab604d4689dd2ca25c9bca69" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" @@ -1618,7 +1624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" -"checksum smallvec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ee4f357e8cd37bf8822e1b964e96fd39e2cb5a0424f8aaa284ccaccc2162411c" +"checksum smallvec 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f90c5e5fe535e48807ab94fc611d323935f39d4660c52b26b96446a7b33aef10" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" diff --git a/chain/Cargo.toml b/chain/Cargo.toml index 66a8f75b..814478a2 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["debris "] [dependencies] -rustc-serialize = "0.3" +rustc-hex = "2" heapsize = "0.4" bitcrypto = { path = "../crypto" } primitives = { path = "../primitives" } diff --git a/chain/README.md b/chain/README.md index 5980bdab..7242e25d 100644 --- a/chain/README.md +++ b/chain/README.md @@ -134,8 +134,8 @@ Whenever a miner mines a block, it includes a special transaction called a coinb **Need a more visual demonstration of the above information? Check out [this awesome website](https://anders.com/blockchain/).** ## Crate Dependencies -#### 1. [rustc-serialize](https://crates.io/crates/rustc-serialize): -*Serialization and deserialization support provided by the compiler.* +#### 1. [rustc-hex](https://crates.io/crates/rustc-hex): +*Serialization and deserialization support from hexadecimal strings.* **One thing to note**: *This crate is deprecated in favor of [`serde`](https://serde.rs/). No new feature development will happen in this crate, although bug fixes proposed through PRs will still be merged. It is very highly recommended by the Rust Library Team that you use [`serde`](https://serde.rs/), not this crate.* diff --git a/chain/src/block.rs b/chain/src/block.rs index f7851439..ad2fed5a 100644 --- a/chain/src/block.rs +++ b/chain/src/block.rs @@ -13,7 +13,7 @@ pub struct Block { impl From<&'static str> for Block { fn from(s: &'static str) -> Self { - deserialize(&s.from_hex().unwrap() as &[u8]).unwrap() + deserialize(&s.from_hex::>().unwrap() as &[u8]).unwrap() } } diff --git a/chain/src/block_header.rs b/chain/src/block_header.rs index 8608938b..89ee4f37 100644 --- a/chain/src/block_header.rs +++ b/chain/src/block_header.rs @@ -36,7 +36,7 @@ impl fmt::Debug for BlockHeader { impl From<&'static str> for BlockHeader { fn from(s: &'static str) -> Self { - deserialize(&s.from_hex().unwrap() as &[u8]).unwrap() + deserialize(&s.from_hex::>().unwrap() as &[u8]).unwrap() } } diff --git a/chain/src/indexed_block.rs b/chain/src/indexed_block.rs index 961ef0b9..56f0485c 100644 --- a/chain/src/indexed_block.rs +++ b/chain/src/indexed_block.rs @@ -84,7 +84,7 @@ impl IndexedBlock { impl From<&'static str> for IndexedBlock { fn from(s: &'static str) -> Self { - deserialize(&s.from_hex().unwrap() as &[u8]).unwrap() + deserialize(&s.from_hex::>().unwrap() as &[u8]).unwrap() } } diff --git a/chain/src/lib.rs b/chain/src/lib.rs index 7aff0c51..a3815427 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -1,4 +1,4 @@ -extern crate rustc_serialize; +extern crate rustc_hex as hex; extern crate heapsize; extern crate primitives; extern crate bitcrypto as crypto; @@ -23,7 +23,6 @@ pub trait RepresentH256 { fn h256(&self) -> hash::H256; } -pub use rustc_serialize::hex; pub use primitives::{hash, bytes, bigint, compact}; pub use block::Block; diff --git a/chain/src/transaction.rs b/chain/src/transaction.rs index 507f0f1f..4b104fb2 100644 --- a/chain/src/transaction.rs +++ b/chain/src/transaction.rs @@ -100,7 +100,7 @@ pub struct Transaction { impl From<&'static str> for Transaction { fn from(s: &'static str) -> Self { - deserialize(&s.from_hex().unwrap() as &[u8]).unwrap() + deserialize(&s.from_hex::>().unwrap() as &[u8]).unwrap() } } diff --git a/keys/Cargo.toml b/keys/Cargo.toml index 0e034f74..c82d04e2 100644 --- a/keys/Cargo.toml +++ b/keys/Cargo.toml @@ -5,7 +5,7 @@ authors = ["debris "] [dependencies] rand = "0.4" -rustc-serialize = "0.3" +rustc-hex = "2" lazy_static = "1.0" base58 = "0.1" eth-secp256k1 = { git = "https://github.com/ethcore/rust-secp256k1" } diff --git a/keys/src/lib.rs b/keys/src/lib.rs index 98f6aa7a..1114b866 100644 --- a/keys/src/lib.rs +++ b/keys/src/lib.rs @@ -1,7 +1,7 @@ //! Bitcoin keys. extern crate rand; -extern crate rustc_serialize; +extern crate rustc_hex as hex; #[macro_use] extern crate lazy_static; extern crate base58; @@ -19,7 +19,6 @@ mod private; mod public; mod signature; -pub use rustc_serialize::hex; pub use primitives::{hash, bytes}; pub use address::{Type, Address}; diff --git a/keys/src/private.rs b/keys/src/private.rs index 8a558cec..bd70b1e2 100644 --- a/keys/src/private.rs +++ b/keys/src/private.rs @@ -108,7 +108,7 @@ impl DisplayLayout for Private { impl fmt::Debug for Private { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(writeln!(f, "network: {:?}", self.network)); - try!(writeln!(f, "secret: {}", self.secret.to_hex())); + try!(writeln!(f, "secret: {}", self.secret.to_hex::())); writeln!(f, "compressed: {}", self.compressed) } } diff --git a/keys/src/public.rs b/keys/src/public.rs index aa240ca2..1887dea9 100644 --- a/keys/src/public.rs +++ b/keys/src/public.rs @@ -92,14 +92,14 @@ impl PartialEq for Public { impl fmt::Debug for Public { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Public::Normal(ref hash) => writeln!(f, "normal: {}", hash.to_hex()), - Public::Compressed(ref hash) => writeln!(f, "compressed: {}", hash.to_hex()), + Public::Normal(ref hash) => writeln!(f, "normal: {}", hash.to_hex::()), + Public::Compressed(ref hash) => writeln!(f, "compressed: {}", hash.to_hex::()), } } } impl fmt::Display for Public { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.to_hex().fmt(f) + self.to_hex::().fmt(f) } } diff --git a/keys/src/signature.rs b/keys/src/signature.rs index 83dad563..fbde2902 100644 --- a/keys/src/signature.rs +++ b/keys/src/signature.rs @@ -12,13 +12,13 @@ pub struct Signature(Vec); impl fmt::Debug for Signature { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.to_hex().fmt(f) + self.0.to_hex::().fmt(f) } } impl fmt::Display for Signature { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.to_hex().fmt(f) + self.0.to_hex::().fmt(f) } } @@ -74,13 +74,13 @@ pub struct CompactSignature(H520); impl fmt::Debug for CompactSignature { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&self.0.to_hex()) + f.write_str(&self.0.to_hex::()) } } impl fmt::Display for CompactSignature { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&self.0.to_hex()) + f.write_str(&self.0.to_hex::()) } } diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 2b39bbfe..daf99bf2 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -5,6 +5,6 @@ authors = ["debris "] [dependencies] heapsize = "0.4" -rustc-serialize = "0.3" +rustc-hex = "2" byteorder = "1.0" bigint = "1.0" diff --git a/primitives/src/bytes.rs b/primitives/src/bytes.rs index 31dae84e..3ecc6a15 100644 --- a/primitives/src/bytes.rs +++ b/primitives/src/bytes.rs @@ -84,7 +84,7 @@ impl io::Write for Bytes { impl fmt::Debug for Bytes { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&self.0.to_hex()) + f.write_str(&self.0.to_hex::()) } } diff --git a/primitives/src/hash.rs b/primitives/src/hash.rs index 713a9eb7..6d6428dd 100644 --- a/primitives/src/hash.rs +++ b/primitives/src/hash.rs @@ -67,7 +67,7 @@ macro_rules! impl_hash { type Err = FromHexError; fn from_str(s: &str) -> Result { - let vec = try!(s.from_hex()); + let vec: Vec = try!(s.from_hex()); match vec.len() { $size => { let mut result = [0u8; $size]; @@ -81,13 +81,13 @@ macro_rules! impl_hash { impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&self.0.to_hex()) + f.write_str(&self.0.to_hex::()) } } impl fmt::Display for $name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&self.0.to_hex()) + f.write_str(&self.0.to_hex::()) } } diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index f2ce5416..64a29a1d 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -1,11 +1,9 @@ extern crate byteorder; #[macro_use] extern crate heapsize; -extern crate rustc_serialize; +extern crate rustc_hex as hex; pub extern crate bigint; pub mod bytes; pub mod compact; pub mod hash; - -pub use rustc_serialize::hex; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 425800c6..cfe26fd2 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -10,7 +10,7 @@ log = "0.4" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" -rustc-serialize = "0.3" +rustc-hex = "2" tokio-core = "0.1.1" jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc.git" } jsonrpc-macros = { git = "https://github.com/ethcore/jsonrpc.git" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index daf1eeb5..2ceaf526 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -1,5 +1,5 @@ extern crate log; -extern crate rustc_serialize; +extern crate rustc_hex as hex; extern crate serde; extern crate serde_json; #[macro_use] @@ -25,8 +25,6 @@ extern crate keys; pub mod v1; pub mod rpc_server; -pub use rustc_serialize::hex; - pub use jsonrpc_core::{MetaIoHandler, Compatibility, Error}; pub use jsonrpc_http_server::tokio_core::reactor::{Remote}; diff --git a/rpc/src/v1/types/bytes.rs b/rpc/src/v1/types/bytes.rs index c7c065ee..84d723e6 100644 --- a/rpc/src/v1/types/bytes.rs +++ b/rpc/src/v1/types/bytes.rs @@ -37,7 +37,7 @@ impl Serialize for Bytes { fn serialize(&self, serializer: S) -> Result where S: Serializer { let mut serialized = String::new(); - serialized.push_str(self.0.to_hex().as_ref()); + serialized.push_str(self.0.to_hex::().as_ref()); serializer.serialize_str(serialized.as_ref()) } } diff --git a/rpc/src/v1/types/hash.rs b/rpc/src/v1/types/hash.rs index 5637f0a7..7d500a57 100644 --- a/rpc/src/v1/types/hash.rs +++ b/rpc/src/v1/types/hash.rs @@ -22,7 +22,7 @@ macro_rules! impl_hash { impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - write!(f, "{}", $other::from(self.0.clone()).to_hex()) + write!(f, "{}", $other::from(self.0.clone()).to_hex::()) } } @@ -89,7 +89,7 @@ macro_rules! impl_hash { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { let mut hex = String::new(); - hex.push_str(&$other::from(self.0.clone()).to_hex()); + hex.push_str(&$other::from(self.0.clone()).to_hex::()); serializer.serialize_str(&hex) } } @@ -111,7 +111,7 @@ macro_rules! impl_hash { return Err(E::invalid_value(Unexpected::Str(value), &self)) } - match value[..].from_hex() { + match value[..].from_hex::>() { Ok(ref v) => { let mut result = [0u8; $size]; result.copy_from_slice(v);