summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-03-02 12:54:32 +0100
committerJustus Winter <justus@sequoia-pgp.org>2021-03-02 12:54:32 +0100
commit6c2c6ca241ba499b699e70fa52b598d909a9e59e (patch)
treee99dd16231628f78edaad436e29d7a61aaeafaff
parentac859bff3b56a5823130c15fae6e0cbbc024c2d5 (diff)
openpgp: Implement fmt::Display for NotationData.
- Fixes #667.
-rw-r--r--openpgp/src/packet/signature/subpacket.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index ac2b55f9..3885375c 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -1086,6 +1086,26 @@ pub struct NotationData {
}
assert_send_and_sync!(NotationData);
+impl fmt::Display for NotationData {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "{}", self.name)?;
+
+ let flags = format!("{:?}", self.flags);
+ if ! flags.is_empty() {
+ write!(f, " ({})", flags)?;
+ }
+
+ if self.flags.human_readable() {
+ write!(f, ": {}", String::from_utf8_lossy(&self.value))?;
+ } else {
+ let hex = crate::fmt::hex::encode(&self.value);
+ write!(f, ": {}", hex)?;
+ }
+
+ Ok(())
+ }
+}
+
impl fmt::Debug for NotationData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut dbg = f.debug_struct("NotationData");