summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-05-12 10:51:48 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-05-12 13:44:28 +0200
commit88729ee45a4e3618e66233655e85f2f8bf55feda (patch)
treecce66cc5d8d887cc8033fe5177af8cc49e869a17
parent31867762cab8e58ac6ca132f5bc0f3e433b279c7 (diff)
openpgp: Implement From<&Packet> for Tag
- Implement `From<&Packet>` for `Tag`. - Also, implement the variant `From<Packet>` for `Tag`.
-rw-r--r--openpgp/src/packet/tag.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/openpgp/src/packet/tag.rs b/openpgp/src/packet/tag.rs
index 38d4e5b5..d99b5ee5 100644
--- a/openpgp/src/packet/tag.rs
+++ b/openpgp/src/packet/tag.rs
@@ -4,6 +4,8 @@ use std::hash::{Hash, Hasher};
use quickcheck::{Arbitrary, Gen};
+use crate::packet::Packet;
+
/// The OpenPGP packet tags as defined in [Section 4.3 of RFC 4880].
///
/// [Section 4.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-4.3
@@ -152,6 +154,18 @@ impl From<&Tag> for u8 {
}
}
+impl From<&Packet> for Tag {
+ fn from(p: &Packet) -> Tag {
+ p.tag()
+ }
+}
+
+impl From<Packet> for Tag {
+ fn from(p: Packet) -> Tag {
+ p.tag()
+ }
+}
+
impl fmt::Display for Tag {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {