diff options
author | Azul <azul@riseup.net> | 2020-10-09 20:05:33 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2020-10-26 17:47:09 +0100 |
commit | d662a80e8f7c96b72708e4124546f72d2712ed40 (patch) | |
tree | beb51cb910bdb1448e4a3edfe4059dca78eb7e8e /openpgp/src/cert.rs | |
parent | 3fc8654d33c8c57542250eda8e910a2ffa0b8a81 (diff) |
openpgp: seal the Preferences trait
[Seal] the `cert::Preferences` trait
so it cannot be implemented for types outside this crate.
Therefore it can be extended in a non-breaking way.
Attempts to implement the trait will not compile.
refers: #538
[seal]: https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed
Diffstat (limited to 'openpgp/src/cert.rs')
-rw-r--r-- | openpgp/src/cert.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs index bcfd79be..abcc3ae5 100644 --- a/openpgp/src/cert.rs +++ b/openpgp/src/cert.rs @@ -437,8 +437,15 @@ type UnknownBundles = ComponentBundles<Unknown>; /// # Ok(()) } /// ``` /// -/// [Section 5.2.3.3]: https://tools.ietf.org/html/rfc4880#section-5.2.3.3 -pub trait Preferences<'a> { +/// # Sealed trait +/// +/// This trait is [sealed] and cannot be implemented for types outside this crate. +/// Therefore it can be extended in a non-breaking way. +/// If you want to implement the trait inside the crate +/// 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 { /// Returns the supported symmetric algorithms ordered by /// preference. /// @@ -2787,6 +2794,8 @@ 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; |