Skip to content

Commit 23efff0

Browse files
committedJul 26, 2019
Improve usability of agreement::UnparsedPublicKey.
1 parent 68f1509 commit 23efff0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎src/agreement.rs

+24
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,35 @@ where
162162
}
163163
}
164164

165+
impl<B: core::fmt::Debug> core::fmt::Debug for UnparsedPublicKey<B>
166+
where
167+
B: AsRef<[u8]>,
168+
{
169+
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
170+
f.debug_struct("UnparsedPublicKey")
171+
.field("algorithm", &self.algorithm)
172+
.field("bytes", &self.bytes)
173+
.finish()
174+
}
175+
}
176+
165177
impl<B: AsRef<[u8]>> UnparsedPublicKey<B> {
166178
/// Constructs a new `UnparsedPublicKey`.
167179
pub fn new(algorithm: &'static Algorithm, bytes: B) -> Self {
168180
Self { algorithm, bytes }
169181
}
182+
183+
/// TODO: doc
184+
#[inline]
185+
pub fn algorithm(&self) -> &'static Algorithm {
186+
self.algorithm
187+
}
188+
189+
/// TODO: doc
190+
#[inline]
191+
pub fn bytes(&self) -> &B {
192+
&self.bytes
193+
}
170194
}
171195

172196
/// Performs a key agreement with an ephemeral private key and the given public

0 commit comments

Comments
 (0)
Please sign in to comment.