diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-06-29 12:37:23 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-06-29 12:38:54 +0200 |
commit | e33289d32e5c520cbf8f8be6567101ae48348eea (patch) | |
tree | 16e954c03f9a769e7d72091f5acbc9bf9f919854 | |
parent | 33f269dfd0da6ab05a8bb1941b9d37ade72b9cc6 (diff) |
openpgp: Make subpacket debug output prettier.
- Format the SubpacketArea as a list instead of a map, and avoid
printing the tag in the subpacket.
-rw-r--r-- | openpgp/src/subpacket.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/openpgp/src/subpacket.rs b/openpgp/src/subpacket.rs index 0f7df9f0..1a53f670 100644 --- a/openpgp/src/subpacket.rs +++ b/openpgp/src/subpacket.rs @@ -378,9 +378,9 @@ impl SubpacketArea { impl fmt::Debug for SubpacketArea { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_map().entries( + f.debug_list().entries( self.iter().map(|(_start, _len, sb)| { - (sb.tag, sb) + Subpacket::from(sb) })) .finish() } @@ -675,7 +675,7 @@ impl<'a> SubpacketValue<'a> { /// Signature subpacket specified by [Section 5.2.3.1 of RFC 4880]. /// /// [Section 5.2.3.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.2.3.1 -#[derive(Debug, PartialEq, Clone)] +#[derive(PartialEq, Clone)] pub struct Subpacket<'a> { /// Critical flag. pub critical: bool, @@ -685,6 +685,18 @@ pub struct Subpacket<'a> { pub value: SubpacketValue<'a>, } +impl<'a> fmt::Debug for Subpacket<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut s = f.debug_struct("Subpacket"); + + if self.critical { + s.field("critical", &self.critical); + } + s.field("value", &self.value); + s.finish() + } +} + impl<'a> Subpacket<'a> { /// Creates a new subpacket. pub fn new(value: SubpacketValue<'a>, critical: bool) -> Result<Subpacket<'a>> { |