make `serde` optional
This commit is contained in:
parent
12e9f4b90b
commit
5c54698bf9
|
@ -25,13 +25,13 @@ unstable = []
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
rand = "0.3"
|
rand = "0.3"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
serde = "1.0"
|
|
||||||
|
|
||||||
[dependencies.rand]
|
[dependencies.rand]
|
||||||
version = "0.3"
|
version = "0.3"
|
||||||
|
@ -41,3 +41,8 @@ optional = true
|
||||||
version = "0.3"
|
version = "0.3"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
|
[dependencies.serde]
|
||||||
|
version = "1.0"
|
||||||
|
optional = true
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
//! # Public and secret keys
|
//! # Public and secret keys
|
||||||
|
|
||||||
use std::marker;
|
#[cfg(any(test, feature = "serde"))] use std::marker;
|
||||||
#[cfg(any(test, feature = "rand"))] use rand::Rng;
|
#[cfg(any(test, feature = "rand"))] use rand::Rng;
|
||||||
#[cfg(any(test, feature = "rustc-serialize"))] use serialize::{Decoder, Decodable, Encoder, Encodable};
|
#[cfg(any(test, feature = "rustc-serialize"))] use serialize::{Decoder, Decodable, Encoder, Encodable};
|
||||||
use serde::{Serialize, Deserialize, Serializer, Deserializer};
|
#[cfg(any(test, feature = "serde"))] use serde::{Serialize, Deserialize, Serializer, Deserializer};
|
||||||
|
|
||||||
use super::{Secp256k1, ContextFlag};
|
use super::{Secp256k1, ContextFlag};
|
||||||
use super::Error::{self, IncapableContext, InvalidPublicKey, InvalidSecretKey};
|
use super::Error::{self, IncapableContext, InvalidPublicKey, InvalidSecretKey};
|
||||||
|
@ -300,6 +300,7 @@ impl Encodable for PublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "serde"))]
|
||||||
impl<'de> Deserialize<'de> for PublicKey {
|
impl<'de> Deserialize<'de> for PublicKey {
|
||||||
fn deserialize<D>(d: D) -> Result<PublicKey, D::Error>
|
fn deserialize<D>(d: D) -> Result<PublicKey, D::Error>
|
||||||
where D: Deserializer<'de>
|
where D: Deserializer<'de>
|
||||||
|
@ -360,6 +361,7 @@ impl<'de> Deserialize<'de> for PublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "serde"))]
|
||||||
impl Serialize for PublicKey {
|
impl Serialize for PublicKey {
|
||||||
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
||||||
where S: Serializer
|
where S: Serializer
|
||||||
|
|
|
@ -38,12 +38,11 @@
|
||||||
|
|
||||||
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
|
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
|
||||||
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
||||||
|
#[cfg(any(test, feature = "serde"))] extern crate serde;
|
||||||
#[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;
|
#[cfg(any(test, feature = "rustc-serialize"))] extern crate rustc_serialize as serialize;
|
||||||
|
|
||||||
extern crate serde;
|
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
use libc::size_t;
|
use libc::size_t;
|
||||||
|
@ -201,6 +200,7 @@ impl Signature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "serde"))]
|
||||||
impl serde::Serialize for Signature {
|
impl serde::Serialize for Signature {
|
||||||
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
||||||
where S: serde::Serializer
|
where S: serde::Serializer
|
||||||
|
@ -210,6 +210,7 @@ impl serde::Serialize for Signature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "serde"))]
|
||||||
impl<'de> serde::Deserialize<'de> for Signature {
|
impl<'de> serde::Deserialize<'de> for Signature {
|
||||||
fn deserialize<D>(d: D) -> Result<Signature, D::Error>
|
fn deserialize<D>(d: D) -> Result<Signature, D::Error>
|
||||||
where D: serde::Deserializer<'de>
|
where D: serde::Deserializer<'de>
|
||||||
|
|
|
@ -146,6 +146,7 @@ macro_rules! impl_array_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "serde"))]
|
||||||
impl<'de> ::serde::Deserialize<'de> for $thing {
|
impl<'de> ::serde::Deserialize<'de> for $thing {
|
||||||
fn deserialize<D>(d: D) -> Result<$thing, D::Error>
|
fn deserialize<D>(d: D) -> Result<$thing, D::Error>
|
||||||
where D: ::serde::Deserializer<'de>
|
where D: ::serde::Deserializer<'de>
|
||||||
|
@ -190,6 +191,7 @@ macro_rules! impl_array_newtype {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "serde"))]
|
||||||
impl ::serde::Serialize for $thing {
|
impl ::serde::Serialize for $thing {
|
||||||
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
||||||
where S: ::serde::Serializer
|
where S: ::serde::Serializer
|
||||||
|
|
Loading…
Reference in New Issue