make `rustc-serialize` crate optional
This commit is contained in:
parent
298929600b
commit
12e9f4b90b
|
@ -27,13 +27,17 @@ default = []
|
|||
[dev-dependencies]
|
||||
serde_json = "1.0"
|
||||
rand = "0.3"
|
||||
rustc-serialize = "0.3"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
rustc-serialize = "0.3"
|
||||
serde = "1.0"
|
||||
|
||||
[dependencies.rand]
|
||||
version = "0.3"
|
||||
optional = true
|
||||
|
||||
[dependencies.rustc-serialize]
|
||||
version = "0.3"
|
||||
optional = true
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use std::marker;
|
||||
#[cfg(any(test, feature = "rand"))] use rand::Rng;
|
||||
use serialize::{Decoder, Decodable, Encoder, Encodable};
|
||||
#[cfg(any(test, feature = "rustc-serialize"))] use serialize::{Decoder, Decodable, Encoder, Encodable};
|
||||
use serde::{Serialize, Deserialize, Serializer, Deserializer};
|
||||
|
||||
use super::{Secp256k1, ContextFlag};
|
||||
|
@ -254,6 +254,7 @@ impl PublicKey {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "rustc-serialize"))]
|
||||
impl Decodable for PublicKey {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<PublicKey, D::Error> {
|
||||
d.read_seq(|d, len| {
|
||||
|
@ -292,6 +293,7 @@ impl From<ffi::PublicKey> for PublicKey {
|
|||
}
|
||||
|
||||
|
||||
#[cfg(any(test, feature = "rustc-serialize"))]
|
||||
impl Encodable for PublicKey {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
self.serialize().encode(s)
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
||||
#[cfg(test)] extern crate serde_json as json;
|
||||
#[cfg(any(test, feature = "rand"))] extern crate rand;
|
||||
#[cfg(any(test, feature = "rustc-serialize"))] extern crate rustc_serialize as serialize;
|
||||
|
||||
extern crate rustc_serialize as serialize;
|
||||
extern crate serde;
|
||||
|
||||
extern crate libc;
|
||||
|
|
|
@ -116,6 +116,7 @@ macro_rules! impl_array_newtype {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "rustc-serialize"))]
|
||||
impl ::serialize::Decodable for $thing {
|
||||
fn decode<D: ::serialize::Decoder>(d: &mut D) -> Result<$thing, D::Error> {
|
||||
use serialize::Decodable;
|
||||
|
@ -137,6 +138,7 @@ macro_rules! impl_array_newtype {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "rustc-serialize"))]
|
||||
impl ::serialize::Encodable for $thing {
|
||||
fn encode<S: ::serialize::Encoder>(&self, s: &mut S)
|
||||
-> Result<(), S::Error> {
|
||||
|
|
Loading…
Reference in New Issue