Merge pull request #515 from jeandudey/2018-08-07-hex

Remove the `rustc-serialize` crate and use the `hex` crate instead.
This commit is contained in:
Svyatoslav Nikolsky 2018-08-11 10:10:30 +03:00 committed by GitHub
commit 89d3e4ee41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 43 additions and 43 deletions

20
Cargo.lock generated
View File

@ -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)" = "<none>"
"checksum rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)" = "<none>"
"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"

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
[dependencies]
rustc-serialize = "0.3"
rustc-hex = "2"
heapsize = "0.4"
bitcrypto = { path = "../crypto" }
primitives = { path = "../primitives" }

View File

@ -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.*

View File

@ -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::<Vec<u8>>().unwrap() as &[u8]).unwrap()
}
}

View File

@ -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::<Vec<u8>>().unwrap() as &[u8]).unwrap()
}
}

View File

@ -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::<Vec<u8>>().unwrap() as &[u8]).unwrap()
}
}

View File

@ -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;

View File

@ -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::<Vec<u8>>().unwrap() as &[u8]).unwrap()
}
}

View File

@ -5,7 +5,7 @@ authors = ["debris <marek.kotewicz@gmail.com>"]
[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" }

View File

@ -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};

View File

@ -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::<String>()));
writeln!(f, "compressed: {}", self.compressed)
}
}

View File

@ -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::<String>()),
Public::Compressed(ref hash) => writeln!(f, "compressed: {}", hash.to_hex::<String>()),
}
}
}
impl fmt::Display for Public {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.to_hex().fmt(f)
self.to_hex::<String>().fmt(f)
}
}

View File

@ -12,13 +12,13 @@ pub struct Signature(Vec<u8>);
impl fmt::Debug for Signature {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.to_hex().fmt(f)
self.0.to_hex::<String>().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::<String>().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::<String>())
}
}
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::<String>())
}
}

View File

@ -5,6 +5,6 @@ authors = ["debris <marek.kotewicz@gmail.com>"]
[dependencies]
heapsize = "0.4"
rustc-serialize = "0.3"
rustc-hex = "2"
byteorder = "1.0"
bigint = "1.0"

View File

@ -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::<String>())
}
}

View File

@ -67,7 +67,7 @@ macro_rules! impl_hash {
type Err = FromHexError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let vec = try!(s.from_hex());
let vec: Vec<u8> = 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::<String>())
}
}
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::<String>())
}
}

View File

@ -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;

View File

@ -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" }

View File

@ -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};

View File

@ -37,7 +37,7 @@ impl Serialize for Bytes {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer {
let mut serialized = String::new();
serialized.push_str(self.0.to_hex().as_ref());
serialized.push_str(self.0.to_hex::<String>().as_ref());
serializer.serialize_str(serialized.as_ref())
}
}

View File

@ -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::<String>())
}
}
@ -89,7 +89,7 @@ macro_rules! impl_hash {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
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::<String>());
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::<Vec<u8>>() {
Ok(ref v) => {
let mut result = [0u8; $size];
result.copy_from_slice(v);