summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-07-21 12:47:32 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-07-21 12:47:32 +0200
commit8cc0d7b85f979276157d5b51c6ee54d404c57d7b (patch)
treecb26677f524d711bf3ad44684c1d74ce6d1bbc68
parent14432de9be3fec6f54496f1e1720d961d636e0b1 (diff)
openpgp: Remove PacketParserResult::is_none.
- There is no variant called `None`, so having this predicate seems wrong. - See #489.
-rw-r--r--openpgp/src/crypto/s2k.rs2
-rw-r--r--openpgp/src/packet_pile.rs8
-rw-r--r--openpgp/src/parse.rs17
-rw-r--r--openpgp/src/parse/packet_pile_parser.rs2
-rw-r--r--openpgp/src/serialize/stream.rs2
5 files changed, 13 insertions, 18 deletions
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index d5553ce4..c09fe75c 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -419,7 +419,7 @@ mod tests {
// Get the next packet.
let (_, ppr) = pp.next().unwrap();
- assert!(ppr.is_none());
+ assert!(ppr.is_eof());
}
}
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs
index af61eb7e..a4dd949f 100644
--- a/openpgp/src/packet_pile.rs
+++ b/openpgp/src/packet_pile.rs
@@ -549,7 +549,7 @@ impl<'a> TryFrom<PacketParserResult<'a>> for PacketPile {
let mut last_position = 0;
- if ppr.is_none() {
+ if ppr.is_eof() {
// Empty message.
return Ok(PacketPile::from(Vec::new()));
}
@@ -600,7 +600,7 @@ impl<'a> TryFrom<PacketParserResult<'a>> for PacketPile {
container.children_mut().unwrap().push(packet);
- if ppr.is_none() {
+ if ppr.is_eof() {
break 'outer;
}
@@ -848,7 +848,7 @@ mod test {
// recurse should now not recurse. Since there is nothing
// following the compressed packet, ppr should be EOF.
let (packet, ppr) = pp.next().unwrap();
- assert!(ppr.is_none());
+ assert!(ppr.is_eof());
// Get the rest of the content and put the initial byte that
// we stole back.
@@ -864,7 +864,7 @@ mod test {
// And we're done...
let ppr = pp.next().unwrap().1;
- assert!(ppr.is_none());
+ assert!(ppr.is_eof());
}
#[test]
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 1944c5bd..6537147c 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -2423,7 +2423,7 @@ fn compressed_data_parser_test () {
}
// And, we're done...
- assert!(ppr.is_none());
+ assert!(ppr.is_eof());
}
}
@@ -3286,7 +3286,7 @@ pub enum PacketParserResult<'a> {
impl<'a> PacketParserResult<'a> {
/// Like `Option::is_none`().
- pub fn is_none(&self) -> bool {
+ pub fn is_eof(&self) -> bool {
if let PacketParserResult::EOF(_) = self {
true
} else {
@@ -3294,14 +3294,9 @@ impl<'a> PacketParserResult<'a> {
}
}
- /// An alias for `is_none`().
- pub fn is_eof(&self) -> bool {
- Self::is_none(self)
- }
-
/// Like `Option::is_some`().
pub fn is_some(&self) -> bool {
- ! Self::is_none(self)
+ ! Self::is_eof(self)
}
/// Like `Option::expect`().
@@ -4725,7 +4720,7 @@ fn packet_parser_reader_interface() {
// Make sure we can still get the next packet (which in this case
// is just EOF).
let (packet, ppr) = pp.recurse().unwrap();
- assert!(ppr.is_none());
+ assert!(ppr.is_eof());
// Since we read all of the data, we expect content to be None.
assert_eq!(packet.unprocessed_body().unwrap().len(), 0);
}
@@ -5205,13 +5200,13 @@ mod test {
"MDC doesn't match");
}
- if ppr.is_none() {
+ if ppr.is_eof() {
// AED packets don't have an MDC packet.
continue;
}
let ppr = consume_until(
ppr, true, &[][..], &[][..]);
- assert!(ppr.is_none());
+ assert!(ppr.is_eof());
}
}
diff --git a/openpgp/src/parse/packet_pile_parser.rs b/openpgp/src/parse/packet_pile_parser.rs
index 44e3f466..2540026a 100644
--- a/openpgp/src/parse/packet_pile_parser.rs
+++ b/openpgp/src/parse/packet_pile_parser.rs
@@ -348,7 +348,7 @@ impl<'a> PacketPileParser<'a> {
/// # Ok(()) }
/// ```
pub fn is_done(&self) -> bool {
- self.ppr.is_none()
+ self.ppr.is_eof()
}
/// Finishes parsing the message and returns the assembled
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs
index c964d595..b19181f3 100644
--- a/openpgp/src/serialize/stream.rs
+++ b/openpgp/src/serialize/stream.rs
@@ -2706,7 +2706,7 @@ mod test {
// Make sure it is the only packet.
let (_, ppr) = pp.recurse().unwrap();
- assert!(ppr.is_none());
+ assert!(ppr.is_eof());
}
// Create some crazy nesting structures, serialize the messages,