diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-04-09 16:42:59 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-09 18:18:30 +0200 |
commit | 2e1eec5fe4157a391a13554ff7df3075cfe043cc (patch) | |
tree | 03ac579ba58d27c08a7ac16ca16f687d1a9456ed /openpgp/examples | |
parent | c1516c59709fa47d13100daddb57657008a793c3 (diff) |
openpgp: Make PacketParserResult a std::result::Result.
- This avoids the partial implementation imitating
std::option::Option, replacing it with std::result::Result.
- As a benefit, std::result::Result is in the prelude, simplifying a
lot of parsing loops.
Diffstat (limited to 'openpgp/examples')
-rw-r--r-- | openpgp/examples/notarize.rs | 6 | ||||
-rw-r--r-- | openpgp/examples/statistics.rs | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/openpgp/examples/notarize.rs b/openpgp/examples/notarize.rs index f7a9842a..c1ad00be 100644 --- a/openpgp/examples/notarize.rs +++ b/openpgp/examples/notarize.rs @@ -8,7 +8,7 @@ extern crate sequoia_openpgp as openpgp; use crate::openpgp::{ armor, Packet, - parse::{Parse, PacketParserResult}, + parse::Parse, serialize::Marshal, }; use crate::openpgp::serialize::stream::{Message, LiteralWriter, Signer}; @@ -78,7 +78,7 @@ fn main() { = openpgp::parse::PacketParser::from_reader(&mut input) .expect("Failed to build parser"); - while let PacketParserResult::Some(mut pp) = ppr { + while let Ok(mut pp) = ppr { if let Err(err) = pp.possible_message() { panic!("Malformed OpenPGP message: {}", err); } @@ -110,7 +110,7 @@ fn main() { ppr = pp.recurse().expect("Failed to recurse").1; } - if let PacketParserResult::EOF(eof) = ppr { + if let Err(eof) = ppr { if let Err(err) = eof.is_message() { panic!("Malformed OpenPGP message: {}", err) } diff --git a/openpgp/examples/statistics.rs b/openpgp/examples/statistics.rs index 1dfebe38..8f2efe8c 100644 --- a/openpgp/examples/statistics.rs +++ b/openpgp/examples/statistics.rs @@ -14,7 +14,7 @@ use crate::openpgp::{Packet, Fingerprint, KeyID, KeyHandle}; use crate::openpgp::types::*; use crate::openpgp::packet::{user_attribute, header::BodyLength, Tag}; use crate::openpgp::packet::signature::subpacket::SubpacketTag; -use crate::openpgp::parse::{Parse, PacketParserResult, PacketParser}; +use crate::openpgp::parse::{Parse, PacketParser}; use crate::openpgp::serialize::MarshalInto; fn main() { @@ -90,7 +90,7 @@ fn main() { .expect("Failed to create reader"); // Iterate over all packets. - while let PacketParserResult::Some(pp) = ppr { + while let Ok(pp) = ppr { // While the packet is in the parser, get some data for later. let size = match pp.header().length() { &BodyLength::Full(n) => Some(n), |