diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-12-19 20:42:24 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-12-20 18:04:56 +0100 |
commit | db3d4cb1dd9251118418ced1a2d1690d0b6b344f (patch) | |
tree | eb53ed339a4fea1a4cb7a871e78f940935dafe82 /openpgp/src/packet_pile.rs | |
parent | b87a71dac7c1f1e2d0464bf0f86c009fe240dd4f (diff) |
openpgp: Use Container for Literal, Unknown.
- Embed Container in Literal and Unknown. This reuses code.
- More importantly, Literal and Unknown now correctly implement
PartialEq.
- Unknown cannot implement Ord. Remove PartialOrd as well, it seems
like an obscure use case to order packets.
- An unfortunate consequence of Unknown not implementing Eq is that
Cert cannot, because it holds unknown packets. We consider that
unacceptable.
- See #93.
Diffstat (limited to 'openpgp/src/packet_pile.rs')
-rw-r--r-- | openpgp/src/packet_pile.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index dff0411b..f3b3d9c9 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -244,10 +244,16 @@ impl PacketPile { return Err(Error::IndexOutOfRange.into()); } - container = match tmp.packets[i].container_mut() { - Some(c) => c, - None => return Err(Error::IndexOutOfRange.into()), - }; + match tmp.packets[i] { + // The structured container types. + Packet::CompressedData(_) + | Packet::SEIP(_) + | Packet::AED(_) + => (), // Ok. + _ => return Err(Error::IndexOutOfRange.into()), + } + container = tmp.packets[i].container_mut() + .expect("The above packets are structured containers"); } return Err(Error::IndexOutOfRange.into()); |