summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet_pile.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-11 11:45:42 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-11 12:55:43 +0100
commit07e61dea837277296953e69ea2b8f9e84f60641a (patch)
tree34033f582f8047b3d8266908bc80cdc57c21af68 /openpgp/src/packet_pile.rs
parent9fbbecd7b75f64c68ec784e86f62dd8c7da590ae (diff)
openpgp: Make the PacketPileParser interface safe.
- Do not expose the PacketParserResult, improve error handling. - Fixes #278.
Diffstat (limited to 'openpgp/src/packet_pile.rs')
-rw-r--r--openpgp/src/packet_pile.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs
index ae533e38..cc3d04da 100644
--- a/openpgp/src/packet_pile.rs
+++ b/openpgp/src/packet_pile.rs
@@ -496,9 +496,9 @@ mod test {
.buffer_unread_content()
.into_packet_pile_parser().unwrap();
- while ppp.recurse() {
- //let pp = ppp.ppo.as_mut().unwrap();
- //eprintln!("{:?}", pp);
+ let mut ppr = ppp.recurse().unwrap();
+ while ppr.is_some() {
+ ppr = ppp.recurse().unwrap();
}
let pile = ppp.finish();
//pile.pretty_print();
@@ -510,14 +510,10 @@ mod test {
.buffer_unread_content()
.into_packet_pile_parser().unwrap();
- while ppp.recurse() {
- if let PacketParserResult::Some(ref pp) = ppp.ppr {
- eprintln!("{:?}", pp);
- } else {
- // If PacketPileParser::recurse returns true, then
- // ppp.ppr is not EOF.
- unreachable!();
- }
+ let mut ppr = ppp.recurse().unwrap();
+ while let Some(pp) = ppr.as_mut() {
+ eprintln!("{:?}", pp);
+ ppr = ppp.recurse().unwrap();
}
let pile = ppp.finish();
pile.pretty_print();