diff --git a/src/context.rs b/src/context.rs index 627e016..e617cd5 100644 --- a/src/context.rs +++ b/src/context.rs @@ -69,16 +69,19 @@ pub trait Signing: Context {} pub trait Verification: Context {} /// Represents the set of capabilities needed for signing with a user preallocated memory. +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SignOnlyPreallocated<'buf> { phantom: PhantomData<&'buf ()>, } /// Represents the set of capabilities needed for verification with a user preallocated memory. +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct VerifyOnlyPreallocated<'buf> { phantom: PhantomData<&'buf ()>, } /// Represents the set of all capabilities with a user preallocated memory. +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct AllPreallocated<'buf> { phantom: PhantomData<&'buf ()>, } @@ -112,14 +115,17 @@ mod alloc_only { /// Represents the set of capabilities needed for signing. #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] + #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum SignOnly {} /// Represents the set of capabilities needed for verification. #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] + #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum VerifyOnly {} /// Represents the set of all capabilities. #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] + #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum All {} impl Signing for SignOnly {} diff --git a/src/key.rs b/src/key.rs index ee52b81..8c0f0a0 100644 --- a/src/key.rs +++ b/src/key.rs @@ -511,7 +511,8 @@ impl Ord for PublicKey { } /// Opaque data structure that holds a keypair consisting of a secret and a public key. -#[derive(Clone)] +// Should secrets implement Copy: https://github.com/rust-bitcoin/rust-secp256k1/issues/363 +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct KeyPair(ffi::KeyPair); impl_display_secret!(KeyPair); diff --git a/src/lib.rs b/src/lib.rs index 4419006..02eb0c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -132,6 +132,8 @@ #![deny(non_snake_case)] #![deny(unused_mut)] #![warn(missing_docs)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] #![cfg_attr(all(not(test), not(feature = "std")), no_std)] diff --git a/src/secret.rs b/src/secret.rs index c174122..28bd80d 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -57,6 +57,7 @@ macro_rules! impl_display_secret { /// /// [`Display`]: fmt::Display /// [`Debug`]: fmt::Debug +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DisplaySecret { secret: [u8; SECRET_KEY_SIZE] }