summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet/unknown.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-19 20:38:42 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-20 18:04:56 +0100
commitf9a9abe78604cae8f9c3cdd398f93e829a561b9d (patch)
tree6c8fca51e9ecf2abb38e0b011e495af4b024a21a /openpgp/src/packet/unknown.rs
parent3a80d2a1866b57b8c07f62ce095d951458e18430 (diff)
openpgp: Use weaker ordering function.
- Previously, Cert::canonicalize relied on Unknown implenting Ord. However, due to streaming, it cannot. Use a weaker ordering function.
Diffstat (limited to 'openpgp/src/packet/unknown.rs')
-rw-r--r--openpgp/src/packet/unknown.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/openpgp/src/packet/unknown.rs b/openpgp/src/packet/unknown.rs
index ed718e1b..adb511bd 100644
--- a/openpgp/src/packet/unknown.rs
+++ b/openpgp/src/packet/unknown.rs
@@ -130,6 +130,17 @@ impl Unknown {
pub fn set_body(&mut self, data: Vec<u8>) -> Vec<u8> {
std::mem::replace(&mut self.body, data)
}
+
+ /// Best effort Ord implementation.
+ ///
+ /// The Cert canonicalization needs to order Unknown packets.
+ /// However, due to potential streaming, Unknown cannot implement
+ /// Eq. This is cheating a little, we simply ignore the streaming
+ /// case.
+ pub(crate) // For cert/mod.rs
+ fn best_effort_cmp(&self, other: &Unknown) -> Ordering {
+ self.tag.cmp(&other.tag).then_with(|| self.body().cmp(&other.body()))
+ }
}
impl From<Unknown> for Packet {