From 149d77f437f2ac2f2dafa4c424a39263b5ffebdc Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 13 Aug 2020 09:47:36 +0200 Subject: openpgp: Add note to enums that cannot be exhaustively matched. --- openpgp/src/crypto/mpi.rs | 12 ++++++++++++ openpgp/src/policy.rs | 3 +++ openpgp/src/types/mod.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 66b2c09b..beda6f86 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -384,6 +384,9 @@ impl fmt::Debug for ProtectedMPI { /// the occasional elliptic curve) in [`Key`] packets. /// /// [`Key`]: ../../packet/enum.Key.html +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. #[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)] pub enum PublicKey { /// RSA public key. @@ -558,6 +561,9 @@ impl Arbitrary for PublicKey { /// /// [`Key`]: ../../packet/enum.Key.html /// [`ProtectedMPI`]: struct.ProtectedMPI.html +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. // Deriving Hash here is okay: PartialEq is manually implemented to // ensure that secrets are compared in constant-time. #[derive(Clone, Hash)] @@ -811,6 +817,9 @@ impl Arbitrary for SecretKeyMaterial { /// [`PKESK`] packets. /// /// [`PKESK`]: ../../packet/enum.PKESK.html +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. #[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)] pub enum Ciphertext { /// RSA ciphertext. @@ -901,6 +910,9 @@ impl Arbitrary for Ciphertext { /// [`Signature`] packets. /// /// [`Signature`]: ../../packet/enum.Signature.html +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. #[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)] pub enum Signature { /// RSA signature. diff --git a/openpgp/src/policy.rs b/openpgp/src/policy.rs index 43c448ae..b8546cf3 100644 --- a/openpgp/src/policy.rs +++ b/openpgp/src/policy.rs @@ -862,6 +862,9 @@ impl<'a> Policy for StandardPolicy<'a> { /// Key sizes put into are buckets, rounding down to the nearest /// bucket. For example, a 3253-bit RSA key is categorized as /// `RSA3072`. +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. #[derive(Clone, Debug)] pub enum AsymmetricAlgorithm { /// RSA with key sizes up to 2048-1 bit. diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index dff23cc3..8bc4009e 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -74,6 +74,9 @@ pub(crate) use timestamp::normalize_systemtime; /// The OpenPGP public key algorithms as defined in [Section 9.1 of /// RFC 4880], and [Section 5 of RFC 6637]. /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// # Examples /// /// ```rust @@ -296,6 +299,9 @@ impl PublicKeyAlgorithm { /// curves. Instead, the curve is specified using an OID prepended to /// the key material. We provide this type to be able to match on the /// curves. +/// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. #[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub enum Curve { /// NIST curve P-256. @@ -530,6 +536,9 @@ impl Arbitrary for Curve { /// /// [`SymmetricAlgorithm::from`]: https://doc.rust-lang.org/std/convert/trait.From.html /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// # Examples /// /// Use `SymmetricAlgorithm` to set the preferred symmetric algorithms on a signature: @@ -686,6 +695,9 @@ impl Arbitrary for SymmetricAlgorithm { /// /// [`AEADAlgorithm::from`]: https://doc.rust-lang.org/std/convert/trait.From.html /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// This feature is [experimental](../index.html#experimental-features). /// /// # Examples @@ -796,6 +808,9 @@ impl Arbitrary for AEADAlgorithm { /// /// [Section 9.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-9.3 /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// # Examples /// /// Use `CompressionAlgorithm` to set the preferred compressions algorithms on @@ -938,6 +953,9 @@ impl Arbitrary for CompressionAlgorithm { /// The OpenPGP hash algorithms as defined in [Section 9.4 of RFC 4880]. /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// # Examples /// /// Use `HashAlgorithm` to set the preferred hash algorithms on a signature: @@ -1075,6 +1093,9 @@ impl Arbitrary for HashAlgorithm { /// /// [Section 5.2.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.2.1 /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// # Examples /// /// Use `SignatureType` to create a timestamp signature: @@ -1235,6 +1256,9 @@ impl Arbitrary for SignatureType { /// /// [Section 5.2.3.23 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.2.3.23 /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// # Examples /// /// ```rust @@ -1496,6 +1520,9 @@ impl ReasonForRevocation { /// /// [Section 5.9 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.9 /// +/// Note: This enum cannot be exhaustively matched to allow future +/// extensions. +/// /// # Examples /// /// Construct a new [`Message`] containing one text literal packet: -- cgit v1.2.3