diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-08-14 15:47:50 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-08-14 17:12:23 +0200 |
commit | 7ac4372f981304856e179262eb9c6e8903a7dafb (patch) | |
tree | d7ca66ebea4ef1c825bb22eee39721eca85f4611 /openpgp/src/message | |
parent | 96be444f05ce80f14a47a515cca813ac0583164d (diff) |
openpgp: Add convenience function.
Diffstat (limited to 'openpgp/src/message')
-rw-r--r-- | openpgp/src/message/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs index e6e74b80..9bff4452 100644 --- a/openpgp/src/message/mod.rs +++ b/openpgp/src/message/mod.rs @@ -21,6 +21,7 @@ use Error; use Packet; use PacketPile; use Message; +use Literal; use packet::Tag; @@ -370,6 +371,21 @@ impl Message { pub fn to_packet_pile(self) -> PacketPile { self.pile } + + /// Returns the body of the message. + /// + /// Returns `None` if no literal data packet is found. This + /// happens if a SEIP container has not been decrypted. + pub fn body(&self) -> Option<&Literal> { + for packet in self.pile.descendants() { + if let &Packet::Literal(ref l) = packet { + return Some(l); + } + } + + // No literal data packet found. + None + } } #[cfg(test)] |