Merge pull request #46 from rust-bitcoin/2018-08-context-debug

add Debug impl to context object
This commit is contained in:
Andrew Poelstra 2018-08-20 18:34:13 +00:00 committed by GitHub
commit 3563c5f305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -546,6 +546,30 @@ impl<C> Drop for Secp256k1<C> {
} }
} }
impl fmt::Debug for Secp256k1<None> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<secp256k1 context {:?}, no capabilities>", self.ctx)
}
}
impl fmt::Debug for Secp256k1<SignOnly> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<secp256k1 context {:?}, signing only>", self.ctx)
}
}
impl fmt::Debug for Secp256k1<VerifyOnly> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<secp256k1 context {:?}, verification only>", self.ctx)
}
}
impl fmt::Debug for Secp256k1<All> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<secp256k1 context {:?}, all capabilities>", self.ctx)
}
}
impl Secp256k1<None> { impl Secp256k1<None> {
/// Creates a new Secp256k1 context with no capabilities (just de/serialization) /// Creates a new Secp256k1 context with no capabilities (just de/serialization)
pub fn without_caps() -> Secp256k1<None> { pub fn without_caps() -> Secp256k1<None> {