From a61bfdab687e9c0b6c5e263ed304f48183059a45 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 3 Mar 2020 23:20:33 +0100 Subject: openpgp: Only impl Serialize for objects that are normally exported. - Add two new traits: `Marshal` and `MarshalInto`. - Implement them instead of `Serialize` and `SerializeInto`. - Only implement `Serialize` and `SerializeInto` for data structures that are normally exported. - This should prevent users from accidentally serializing a bare signature (`Signature`) when they meant to serialize a signature packet (`Packet`), for instance. - Fixes #368. --- net/src/wkd.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'net/src') diff --git a/net/src/wkd.rs b/net/src/wkd.rs index fe7976a5..4c9e0283 100644 --- a/net/src/wkd.rs +++ b/net/src/wkd.rs @@ -33,7 +33,7 @@ use crate::openpgp::{ Cert, }; use crate::openpgp::parse::Parse; -use crate::openpgp::serialize::Serialize; +use crate::openpgp::serialize::Marshal; use crate::openpgp::types::HashAlgorithm; use crate::openpgp::cert::prelude::*; @@ -404,7 +404,9 @@ impl KeyRing { } } -impl Serialize for KeyRing { +impl crate::openpgp::serialize::Serialize for KeyRing {} + +impl Marshal for KeyRing { fn serialize(&self, o: &mut dyn std::io::Write) -> Result<()> { for cert in self.0.values() { cert.serialize(o)?; @@ -423,8 +425,6 @@ impl Serialize for KeyRing { #[cfg(test)] mod tests { - use crate::openpgp::serialize::Serialize; - use super::*; use self::Variant::*; -- cgit v1.2.3