summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert.rs
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2020-11-17 15:54:54 +0100
committerAzul <azul@riseup.net>2020-11-24 12:25:37 +0100
commitb21f22daa452f98845ab9c0ad0cf4b36bbe31251 (patch)
tree60a7418f0ef09e40d268185f1271635db8286fca /openpgp/src/cert.rs
parent43ad20c16ccee274cc4ecdb327e70e2349fa12ad (diff)
openpgp: seal traits in cert::amalgamation
- Seal `ValidAmalgamation`, `ValidateAmalgamation` and `key::PrimaryKey` - Sealing traits so they cannot be implemented outside the openpgp crate. This way we can extend the traits without breaking the API compatibility. Every implementation of a sealed trait needs to also implement the `seal::Sealed` marker trait. - Implementing `seal::Sealed` for `ValidKeyAmalgamation<'a, P, R, R2>` also implements it for - `ValidPrimaryKeyAmalgamation<'a, P>` - `ValidSubordinateKeyAmalgamation<'a, P>` - `ValidErasedKeyAmalgamation<'a, P>` Therefore these can implement `ValidateAmalgamation` and `key::PrimaryKey` without explicitly implementing `seal::Sealed` - See #538.
Diffstat (limited to 'openpgp/src/cert.rs')
-rw-r--r--openpgp/src/cert.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs
index 1b32d87f..f6232bc6 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -162,6 +162,7 @@ use crate::{
packet::Unknown,
Packet,
PacketPile,
+ seal,
KeyID,
Fingerprint,
KeyHandle,
@@ -445,7 +446,7 @@ type UnknownBundles = ComponentBundles<Unknown>;
/// you also need to implement the `seal::Sealed` marker trait.
///
/// [sealed]: https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed
-pub trait Preferences<'a>: crate::seal::Sealed {
+pub trait Preferences<'a>: seal::Sealed {
/// Returns the supported symmetric algorithms ordered by
/// preference.
///
@@ -2798,8 +2799,6 @@ pub struct ValidCert<'a> {
time: time::SystemTime,
}
-impl<'a> crate::seal::Sealed for ValidCert<'a> {}
-
impl<'a> std::ops::Deref for ValidCert<'a> {
type Target = Cert;
@@ -3393,7 +3392,8 @@ macro_rules! impl_pref {
}
}
-impl<'a> crate::cert::Preferences<'a> for ValidCert<'a>
+impl<'a> seal::Sealed for ValidCert<'a> {}
+impl<'a> Preferences<'a> for ValidCert<'a>
{
impl_pref!(preferred_symmetric_algorithms, &'a [SymmetricAlgorithm]);
impl_pref!(preferred_hash_algorithms, &'a [HashAlgorithm]);