Skip to content

Commit 385e61e

Browse files
authored
Add #[non_exhaustive] to public API enums likely to grow
1 parent 7082d71 commit 385e61e

12 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/crypto/keying.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl std::fmt::Debug for KeyingMaterial {
2727

2828
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2929
#[allow(non_camel_case_types)]
30+
#[non_exhaustive]
3031
/// Supported SRTP protection profiles (RFC 5764).
3132
pub enum SrtpProfile {
3233
/// SRTP_AES128_CM_HMAC_SHA1_80 (RFC 5764)

src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Public error type returned by the high-level DTLS API.
22
33
#[derive(Debug)]
4+
#[non_exhaustive]
45
/// Errors returned by DTLS processing functions.
56
pub enum Error {
67
/// Parser requested more data

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ impl fmt::Debug for Dtls {
500500
}
501501

502502
/// Output events produced by the DTLS engine when polled.
503+
#[non_exhaustive]
503504
pub enum Output<'a> {
504505
/// A DTLS record to transmit on the wire.
505506
Packet(&'a [u8]),

src/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ impl Random {
8282
/// Used for Elliptic Curve Diffie-Hellman Ephemeral (ECDHE) key exchange.
8383
/// The same named groups are used in both DTLS 1.2 and DTLS 1.3.
8484
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
85+
#[non_exhaustive]
8586
pub enum NamedGroup {
8687
/// sect163k1 (deprecated).
8788
Sect163k1,
@@ -536,6 +537,7 @@ impl PartialOrd for Sequence {
536537
/// separate.
537538
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
538539
#[allow(non_camel_case_types)]
540+
#[non_exhaustive]
539541
pub enum SignatureScheme {
540542
/// ECDSA with P-256 and SHA-256.
541543
ECDSA_SECP256R1_SHA256,
@@ -700,6 +702,7 @@ impl SignatureScheme {
700702
/// and hash function. Key exchange is negotiated separately via key_share.
701703
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
702704
#[allow(non_camel_case_types)]
705+
#[non_exhaustive]
703706
pub enum Dtls13CipherSuite {
704707
/// TLS_AES_128_GCM_SHA256.
705708
AES_128_GCM_SHA256,

tests/auto/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn drain_outputs(endpoint: &mut Dtls) -> DrainedOutputs {
4949
result.timeout = Some(t);
5050
break;
5151
}
52+
_ => {}
5253
}
5354
}
5455
result

tests/dtls12/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ pub fn drain_outputs(endpoint: &mut Dtls) -> DrainedOutputs {
134134
result.timeout = Some(t);
135135
break;
136136
}
137+
_ => {}
137138
}
138139
}
139140
result

tests/dtls12/fragmentation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ fn run_client_server_with_mtu(mtu: usize) -> (usize, usize) {
114114
Output::Timeout(_) => {
115115
continue_polling = false;
116116
}
117+
_ => {}
117118
}
118119
}
119120

tests/dtls12/ossl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ fn dtls12_ossl_client_handshake() {
118118
// so we stop polling in this iteration
119119
continue_polling = false;
120120
}
121+
_ => {}
121122
}
122123
}
123124

@@ -315,6 +316,7 @@ fn dtls12_ossl_server_handshake() {
315316
server_received_data.extend_from_slice(data);
316317
}
317318
Output::Timeout(_) => break,
319+
_ => {}
318320
}
319321
}
320322

tests/dtls13/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn drain_outputs(endpoint: &mut Dtls) -> DrainedOutputs {
4949
result.timeout = Some(t);
5050
break;
5151
}
52+
_ => {}
5253
}
5354
}
5455
result

tests/dtls13/handshake.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ fn dtls13_srtp_keying_material_correct_size() {
250250
SrtpProfile::AEAD_AES_128_GCM => 2 * (16 + 12), // 2 * (key + salt) for AES-128-GCM
251251
SrtpProfile::AEAD_AES_256_GCM => 2 * (32 + 12), // 2 * (key + salt) for AES-256-GCM
252252
SrtpProfile::AES128_CM_SHA1_80 => 2 * (16 + 14), // 2 * (key + salt) for AES-128-CM
253+
_ => unreachable!(),
253254
};
254255

255256
assert_eq!(

0 commit comments

Comments
 (0)