summaryrefslogtreecommitdiffstats
path: root/openpgp/src/types/mod.rs
diff options
context:
space:
mode:
authorWiktor Kwapisiewicz <wiktor@metacode.biz>2022-06-10 11:05:09 +0200
committerWiktor Kwapisiewicz <wiktor@metacode.biz>2022-06-10 11:37:31 +0200
commit956f6247ace267c6d14c6c71157c3fbd0bfb2c25 (patch)
tree2b381d5ca02dbe0a0cc051ebdcfb5150fcb6da2a /openpgp/src/types/mod.rs
parentca93d5c5a6a5a61e1427c836f531abe3f39cac6d (diff)
openpgp: Add docs to PublicKeyAlgorithm's Display impl.
- Adjust the attribute to reduce the number of #[allow]s.
Diffstat (limited to 'openpgp/src/types/mod.rs')
-rw-r--r--openpgp/src/types/mod.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs
index f949c506..f7f615f0 100644
--- a/openpgp/src/types/mod.rs
+++ b/openpgp/src/types/mod.rs
@@ -239,11 +239,29 @@ impl From<PublicKeyAlgorithm> for u8 {
}
}
+/// Formats the public key algorithm name.
+///
+/// There are two ways the public key algorithm name can be formatted.
+/// By default the short name is used. The alternate format uses the
+/// full public key algorithm name.
+///
+/// # Examples
+///
+/// ```
+/// use sequoia_openpgp as openpgp;
+/// use openpgp::types::PublicKeyAlgorithm;
+///
+/// // default, short format
+/// assert_eq!("ECDH", format!("{}", PublicKeyAlgorithm::ECDH));
+///
+/// // alternate, long format
+/// assert_eq!("ECDH public key algorithm", format!("{:#}", PublicKeyAlgorithm::ECDH));
+/// ```
impl fmt::Display for PublicKeyAlgorithm {
+ #[allow(deprecated)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use crate::PublicKeyAlgorithm::*;
if f.alternate() {
- #[allow(deprecated)]
match *self {
RSAEncryptSign => f.write_str("RSA (Encrypt or Sign)"),
RSAEncrypt => f.write_str("RSA Encrypt-Only"),
@@ -260,7 +278,6 @@ impl fmt::Display for PublicKeyAlgorithm {
f.write_fmt(format_args!("Unknown public key algorithm {}", u)),
}
} else {
- #[allow(deprecated)]
match *self {
RSAEncryptSign => f.write_str("RSA"),
RSAEncrypt => f.write_str("RSA"),