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