Skip to content

Commit 9792112

Browse files
author
yngrtc
committed
fix clippy default warning
1 parent 5aa49c0 commit 9792112

File tree

42 files changed

+108
-372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+108
-372
lines changed

dtls/src/config.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,36 +134,26 @@ pub(crate) type PskCallback = Arc<dyn (Fn(&[u8]) -> Result<Vec<u8>>) + Send + Sy
134134

135135
// ClientAuthType declares the policy the server will follow for
136136
// TLS Client Authentication.
137-
#[derive(Copy, Clone, PartialEq, Eq)]
137+
#[derive(Default, Copy, Clone, PartialEq, Eq)]
138138
pub enum ClientAuthType {
139+
#[default]
139140
NoClientCert = 0,
140141
RequestClientCert = 1,
141142
RequireAnyClientCert = 2,
142143
VerifyClientCertIfGiven = 3,
143144
RequireAndVerifyClientCert = 4,
144145
}
145146

146-
impl Default for ClientAuthType {
147-
fn default() -> Self {
148-
ClientAuthType::NoClientCert
149-
}
150-
}
151-
152147
// ExtendedMasterSecretType declares the policy the client and server
153148
// will follow for the Extended Master Secret extension
154-
#[derive(PartialEq, Eq, Copy, Clone)]
149+
#[derive(Default, PartialEq, Eq, Copy, Clone)]
155150
pub enum ExtendedMasterSecretType {
151+
#[default]
156152
Request = 0,
157153
Require = 1,
158154
Disable = 2,
159155
}
160156

161-
impl Default for ExtendedMasterSecretType {
162-
fn default() -> Self {
163-
ExtendedMasterSecretType::Request
164-
}
165-
}
166-
167157
pub(crate) fn validate_config(is_client: bool, config: &Config) -> Result<()> {
168158
if is_client && config.psk.is_some() && config.psk_identity_hint.is_none() {
169159
return Err(Error::ErrPskAndIdentityMustBeSetForClient);

dtls/src/content.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ use crate::error::*;
77
use std::io::{Read, Write};
88

99
// https://tools.ietf.org/html/rfc4346#section-6.2.1
10-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
10+
#[derive(Default, Copy, Clone, PartialEq, Eq, Debug)]
1111
pub enum ContentType {
1212
ChangeCipherSpec = 20,
1313
Alert = 21,
1414
Handshake = 22,
1515
ApplicationData = 23,
16+
#[default]
1617
Invalid,
1718
}
1819

@@ -28,12 +29,6 @@ impl From<u8> for ContentType {
2829
}
2930
}
3031

31-
impl Default for ContentType {
32-
fn default() -> Self {
33-
ContentType::Invalid
34-
}
35-
}
36-
3732
#[derive(PartialEq, Debug, Clone)]
3833
pub enum Content {
3934
ChangeCipherSpec(ChangeCipherSpec),

dtls/src/handshake/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use handshake_message_server_hello_done::*;
3434
use handshake_message_server_key_exchange::*;
3535

3636
// https://tools.ietf.org/html/rfc5246#section-7.4
37-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
37+
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq, Hash)]
3838
pub enum HandshakeType {
3939
HelloRequest = 0,
4040
ClientHello = 1,
@@ -47,6 +47,7 @@ pub enum HandshakeType {
4747
CertificateVerify = 15,
4848
ClientKeyExchange = 16,
4949
Finished = 20,
50+
#[default]
5051
Invalid,
5152
}
5253

@@ -88,12 +89,6 @@ impl From<u8> for HandshakeType {
8889
}
8990
}
9091

91-
impl Default for HandshakeType {
92-
fn default() -> Self {
93-
HandshakeType::Invalid
94-
}
95-
}
96-
9792
#[derive(PartialEq, Debug, Clone)]
9893
pub enum HandshakeMessage {
9994
//HelloRequest(errNotImplemented),

mdns/src/message/header.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ impl Header {
5454
}
5555
}
5656

57-
#[derive(Copy, Clone, PartialOrd, PartialEq, Eq)]
57+
#[derive(Default, Copy, Clone, PartialOrd, PartialEq, Eq)]
5858
pub enum Section {
59+
#[default]
5960
NotStarted = 0,
6061
Header = 1,
6162
Questions = 2,
@@ -65,12 +66,6 @@ pub enum Section {
6566
Done = 6,
6667
}
6768

68-
impl Default for Section {
69-
fn default() -> Self {
70-
Section::NotStarted
71-
}
72-
}
73-
7469
impl From<u8> for Section {
7570
fn from(v: u8) -> Self {
7671
match v {

mdns/src/message/mod.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::fmt;
2222
// Message formats
2323

2424
// A Type is a type of DNS request and response.
25-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
25+
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
2626
pub enum DnsType {
2727
// ResourceHeader.Type and question.Type
2828
A = 1,
@@ -43,15 +43,10 @@ pub enum DnsType {
4343
Axfr = 252,
4444
All = 255,
4545

46+
#[default]
4647
Unsupported = 0,
4748
}
4849

49-
impl Default for DnsType {
50-
fn default() -> Self {
51-
DnsType::Unsupported
52-
}
53-
}
54-
5550
impl From<u16> for DnsType {
5651
fn from(v: u16) -> Self {
5752
match v {
@@ -167,9 +162,10 @@ impl DnsClass {
167162
pub type OpCode = u16;
168163

169164
// An RCode is a DNS response status code.
170-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
165+
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
171166
pub enum RCode {
172167
// Message.Rcode
168+
#[default]
173169
Success = 0,
174170
FormatError = 1,
175171
ServerFailure = 2,
@@ -179,12 +175,6 @@ pub enum RCode {
179175
Unsupported,
180176
}
181177

182-
impl Default for RCode {
183-
fn default() -> Self {
184-
RCode::Success
185-
}
186-
}
187-
188178
impl From<u8> for RCode {
189179
fn from(v: u8) -> Self {
190180
match v {

media/src/io/h264_reader/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ use std::io::Read;
99

1010
/// NalUnitType is the type of a NAL
1111
/// Enums for NalUnitTypes
12-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
12+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
1313
pub enum NalUnitType {
1414
/// Unspecified
15+
#[default]
1516
Unspecified = 0,
1617
/// Coded slice of a non-IDR picture
1718
CodedSliceNonIdr = 1,
@@ -48,12 +49,6 @@ pub enum NalUnitType {
4849
// 24..31 // Unspecified
4950
}
5051

51-
impl Default for NalUnitType {
52-
fn default() -> Self {
53-
NalUnitType::Unspecified
54-
}
55-
}
56-
5752
impl fmt::Display for NalUnitType {
5853
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5954
let s = match *self {

rtcp/src/extended_report/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ const XR_HEADER_LENGTH: usize = 4;
3232

3333
/// BlockType specifies the type of report in a report block
3434
/// Extended Report block types from RFC 3611.
35-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
35+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
3636
pub enum BlockType {
37+
#[default]
3738
Unknown = 0,
3839
LossRLE = 1, // RFC 3611, section 4.1
3940
DuplicateRLE = 2, // RFC 3611, section 4.2
@@ -44,12 +45,6 @@ pub enum BlockType {
4445
VoIPMetrics = 7, // RFC 3611, section 4.7
4546
}
4647

47-
impl Default for BlockType {
48-
fn default() -> Self {
49-
BlockType::Unknown
50-
}
51-
}
52-
5348
impl From<u8> for BlockType {
5449
fn from(v: u8) -> Self {
5550
match v {

rtcp/src/extended_report/ssr.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,14 @@ impl fmt::Display for StatisticsSummaryReportBlock {
6060

6161
/// TTLorHopLimitType encodes values for the ToH field in
6262
/// a StatisticsSummaryReportBlock
63-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
63+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
6464
pub enum TTLorHopLimitType {
65+
#[default]
6566
Missing = 0,
6667
IPv4 = 1,
6768
IPv6 = 2,
6869
}
6970

70-
impl Default for TTLorHopLimitType {
71-
fn default() -> Self {
72-
TTLorHopLimitType::Missing
73-
}
74-
}
75-
7671
impl From<u8> for TTLorHopLimitType {
7772
fn from(v: u8) -> Self {
7873
match v {

rtcp/src/header.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use bytes::{Buf, BufMut};
55

66
/// PacketType specifies the type of an RTCP packet
77
/// RTCP packet types registered with IANA. See: https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-4
8-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
8+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
99
#[repr(u8)]
1010
pub enum PacketType {
11+
#[default]
1112
Unsupported = 0,
1213
SenderReport = 200, // RFC 3550, 6.4.1
1314
ReceiverReport = 201, // RFC 3550, 6.4.2
@@ -19,12 +20,6 @@ pub enum PacketType {
1920
ExtendedReport = 207, // RFC 3611
2021
}
2122

22-
impl Default for PacketType {
23-
fn default() -> Self {
24-
PacketType::Unsupported
25-
}
26-
}
27-
2823
/// Transport and Payload specific feedback messages overload the count field to act as a message type. those are listed here
2924
pub const FORMAT_SLI: u8 = 2;
3025
/// Transport and Payload specific feedback messages overload the count field to act as a message type. those are listed here

rtcp/src/source_description/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ const SDES_TEXT_OFFSET: usize = 2;
2020

2121
/// SDESType is the item type used in the RTCP SDES control packet.
2222
/// RTP SDES item types registered with IANA. See: https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-5
23-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
23+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
2424
#[repr(u8)]
2525
pub enum SdesType {
26-
SdesEnd = 0, // end of SDES list RFC 3550, 6.5
26+
#[default]
27+
SdesEnd = 0, // end of SDES list RFC 3550, 6.5
2728
SdesCname = 1, // canonical name RFC 3550, 6.5.1
2829
SdesName = 2, // user name RFC 3550, 6.5.2
2930
SdesEmail = 3, // user's electronic mail address RFC 3550, 6.5.3
@@ -34,12 +35,6 @@ pub enum SdesType {
3435
SdesPrivate = 8, // private extensions RFC 3550, 6.5.8 (not implemented)
3536
}
3637

37-
impl Default for SdesType {
38-
fn default() -> Self {
39-
SdesType::SdesEnd
40-
}
41-
}
42-
4338
impl fmt::Display for SdesType {
4439
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4540
let s = match self {

0 commit comments

Comments
 (0)