diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-02-21 12:00:14 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-02-21 12:00:14 +0100 |
commit | 923a649ac169fc5210b730017e23557b74ccceaf (patch) | |
tree | c0daca584f3357ae28130b0dc3685172f81b1bef | |
parent | f8c73c29c89557c4ec00f72576e8f4add62e66d7 (diff) |
openpgp: Mark enum Signature as non-exhaustive.
-rw-r--r-- | openpgp/src/crypto/mpis.rs | 7 | ||||
-rw-r--r-- | openpgp/src/serialize/mod.rs | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/openpgp/src/crypto/mpis.rs b/openpgp/src/crypto/mpis.rs index ff3cfb5b..b78b513f 100644 --- a/openpgp/src/crypto/mpis.rs +++ b/openpgp/src/crypto/mpis.rs @@ -953,6 +953,10 @@ pub enum Signature { /// Any data that failed to parse. rest: Box<[u8]>, }, + + /// This marks this enum as non-exhaustive. Do not use this + /// variant. + #[doc(hidden)] __Nonexhaustive, } impl Signature { @@ -982,6 +986,8 @@ impl Signature { &Unknown { ref mpis, ref rest } => mpis.iter().map(|m| 2 + m.value.len()).sum::<usize>() + rest.len(), + + __Nonexhaustive => unreachable!(), } } } @@ -1194,6 +1200,7 @@ mod tests { ECDSA, cur.into_inner()).unwrap(), Signature::Unknown { .. } => unreachable!(), + Signature::__Nonexhaustive => unreachable!(), }; sig == sig_ diff --git a/openpgp/src/serialize/mod.rs b/openpgp/src/serialize/mod.rs index 9b477931..8a857335 100644 --- a/openpgp/src/serialize/mod.rs +++ b/openpgp/src/serialize/mod.rs @@ -860,6 +860,8 @@ impl Serialize for crypto::mpis::Signature { } w.write_all(rest)?; } + + __Nonexhaustive => unreachable!(), } Ok(()) @@ -890,6 +892,8 @@ impl SerializeInto for crypto::mpis::Signature { mpis.iter().map(|mpi| mpi.serialized_len()).sum::<usize>() + rest.len() } + + __Nonexhaustive => unreachable!(), } } |