Skip to content

Commit 9f5d8c4

Browse files
committed
fix clippy/fmt
1 parent ba5ceef commit 9f5d8c4

File tree

11 files changed

+33
-82
lines changed

11 files changed

+33
-82
lines changed

data/src/message/message_channel_open.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ pub const CHANNEL_PRIORITY_NORMAL: u16 = 256;
1717
pub const CHANNEL_PRIORITY_HIGH: u16 = 512;
1818
pub const CHANNEL_PRIORITY_EXTRA_HIGH: u16 = 1024;
1919

20-
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
20+
#[derive(Default, Eq, PartialEq, Copy, Clone, Debug)]
2121
pub enum ChannelType {
2222
// `Reliable` determines the Data Channel provides a
2323
// reliable in-order bi-directional communication.
24+
#[default]
2425
Reliable,
2526
// `ReliableUnordered` determines the Data Channel
2627
// provides a reliable unordered bi-directional communication.
@@ -46,12 +47,6 @@ pub enum ChannelType {
4647
PartialReliableTimedUnordered,
4748
}
4849

49-
impl Default for ChannelType {
50-
fn default() -> Self {
51-
Self::Reliable
52-
}
53-
}
54-
5550
impl MarshalSize for ChannelType {
5651
fn marshal_size(&self) -> usize {
5752
CHANNEL_TYPE_LEN

ice/src/candidate/mod.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ pub trait Candidate: fmt::Display {
8989
}
9090

9191
/// Represents the type of candidate `CandidateType` enum.
92-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
92+
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
9393
pub enum CandidateType {
9494
#[serde(rename = "unspecified")]
95+
#[default]
9596
Unspecified,
9697
#[serde(rename = "host")]
9798
Host,
@@ -117,12 +118,6 @@ impl fmt::Display for CandidateType {
117118
}
118119
}
119120

120-
impl Default for CandidateType {
121-
fn default() -> Self {
122-
Self::Unspecified
123-
}
124-
}
125-
126121
impl CandidateType {
127122
/// Returns the preference weight of a `CandidateType`.
128123
///
@@ -171,9 +166,10 @@ impl fmt::Display for CandidateRelatedAddress {
171166
}
172167

173168
/// Represent the ICE candidate pair state.
174-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
169+
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
175170
pub enum CandidatePairState {
176171
#[serde(rename = "unspecified")]
172+
#[default]
177173
Unspecified = 0,
178174

179175
/// Means a check has not been performed for this pair.
@@ -206,12 +202,6 @@ impl From<u8> for CandidatePairState {
206202
}
207203
}
208204

209-
impl Default for CandidatePairState {
210-
fn default() -> Self {
211-
Self::Unspecified
212-
}
213-
}
214-
215205
impl fmt::Display for CandidatePairState {
216206
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
217207
let s = match *self {

ice/src/control/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,14 @@ impl Getter for AttrControl {
108108

109109
/// Represents ICE agent role, which can be controlling or controlled.
110110
/// Possible ICE agent roles.
111-
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
111+
#[derive(Default, PartialEq, Eq, Copy, Clone, Debug)]
112112
pub enum Role {
113+
#[default]
113114
Controlling,
114115
Controlled,
115116
Unspecified,
116117
}
117118

118-
impl Default for Role {
119-
fn default() -> Self {
120-
Self::Controlling
121-
}
122-
}
123-
124119
impl From<&str> for Role {
125120
fn from(raw: &str) -> Self {
126121
match raw {

ice/src/mdns/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,19 @@ use uuid::Uuid;
1212
use crate::error::Result;
1313

1414
/// Represents the different Multicast modes that ICE can run.
15-
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
15+
#[derive(Default, PartialEq, Eq, Debug, Copy, Clone)]
1616
pub enum MulticastDnsMode {
1717
/// Means remote mDNS candidates will be discarded, and local host candidates will use IPs.
1818
Disabled,
1919

2020
/// Means remote mDNS candidates will be accepted, and local host candidates will use IPs.
21+
#[default]
2122
QueryOnly,
2223

2324
/// Means remote mDNS candidates will be accepted, and local host candidates will use mDNS.
2425
QueryAndGather,
2526
}
2627

27-
impl Default for MulticastDnsMode {
28-
fn default() -> Self {
29-
Self::QueryOnly
30-
}
31-
}
32-
3328
pub(crate) fn generate_multicast_dns_name() -> String {
3429
// https://tools.ietf.org/id/draft-ietf-rtcweb-mdns-ice-candidates-02.html#gathering
3530
// The unique name MUST consist of a version 4 UUID as defined in [RFC4122], followed by “.local”.

ice/src/network_type/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ pub fn supported_network_types() -> Vec<NetworkType> {
2222
}
2323

2424
/// Represents the type of network.
25-
#[derive(PartialEq, Debug, Copy, Clone, Eq, Hash, Serialize, Deserialize)]
25+
#[derive(Default, PartialEq, Debug, Copy, Clone, Eq, Hash, Serialize, Deserialize)]
2626
pub enum NetworkType {
2727
#[serde(rename = "unspecified")]
28+
#[default]
2829
Unspecified,
2930

3031
/// Indicates UDP over IPv4.
@@ -69,12 +70,6 @@ impl fmt::Display for NetworkType {
6970
}
7071
}
7172

72-
impl Default for NetworkType {
73-
fn default() -> Self {
74-
Self::Unspecified
75-
}
76-
}
77-
7873
impl NetworkType {
7974
/// Returns true when network is UDP4 or UDP6.
8075
#[must_use]

ice/src/state/mod.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ mod state_test;
44
use std::fmt;
55

66
/// An enum showing the state of a ICE Connection List of supported States.
7-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
7+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
88
pub enum ConnectionState {
9+
#[default]
910
Unspecified,
1011

1112
/// ICE agent is gathering addresses.
@@ -30,12 +31,6 @@ pub enum ConnectionState {
3031
Closed,
3132
}
3233

33-
impl Default for ConnectionState {
34-
fn default() -> Self {
35-
Self::Unspecified
36-
}
37-
}
38-
3934
impl fmt::Display for ConnectionState {
4035
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4136
let s = match *self {
@@ -68,8 +63,9 @@ impl From<u8> for ConnectionState {
6863
}
6964

7065
/// Describes the state of the candidate gathering process.
71-
#[derive(PartialEq, Eq, Copy, Clone)]
66+
#[derive(Default, PartialEq, Eq, Copy, Clone)]
7267
pub enum GatheringState {
68+
#[default]
7369
Unspecified,
7470

7571
/// Indicates candidate gathering is not yet started.
@@ -93,12 +89,6 @@ impl From<u8> for GatheringState {
9389
}
9490
}
9591

96-
impl Default for GatheringState {
97-
fn default() -> Self {
98-
Self::Unspecified
99-
}
100-
}
101-
10292
impl fmt::Display for GatheringState {
10393
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10494
let s = match *self {

ice/src/tcp_type/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ use std::fmt;
1010
/// * [RFC 6544 §4.5]
1111
///
1212
/// [RFC 6544 §4.5]: https://tools.ietf.org/html/rfc6544#section-4.5
13-
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
13+
#[derive(Default, PartialEq, Eq, Debug, Copy, Clone)]
1414
pub enum TcpType {
1515
/// The default value. For example UDP candidates do not need this field.
16+
#[default]
1617
Unspecified,
1718
/// Active TCP candidate, which initiates TCP connections.
1819
Active,
@@ -45,9 +46,3 @@ impl fmt::Display for TcpType {
4546
write!(f, "{s}")
4647
}
4748
}
48-
49-
impl Default for TcpType {
50-
fn default() -> Self {
51-
Self::Unspecified
52-
}
53-
}

ice/src/url/mod.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use stun::{DEFAULT_PORT, DEFAULT_TLS_PORT};
99
use crate::error::*;
1010

1111
/// The type of server used in the ice.URL structure.
12-
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
12+
#[derive(Default, PartialEq, Eq, Debug, Copy, Clone)]
1313
pub enum SchemeType {
1414
/// The URL represents a STUN server.
1515
Stun,
@@ -24,15 +24,10 @@ pub enum SchemeType {
2424
Turns,
2525

2626
/// Default public constant to use for "enum" like struct comparisons when no value was defined.
27+
#[default]
2728
Unknown,
2829
}
2930

30-
impl Default for SchemeType {
31-
fn default() -> Self {
32-
Self::Unknown
33-
}
34-
}
35-
3631
impl From<&str> for SchemeType {
3732
/// Defines a procedure for creating a new `SchemeType` from a raw
3833
/// string naming the scheme type.
@@ -61,9 +56,10 @@ impl fmt::Display for SchemeType {
6156
}
6257

6358
/// The transport protocol type that is used in the `ice::url::Url` structure.
64-
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
59+
#[derive(Default, PartialEq, Eq, Debug, Copy, Clone)]
6560
pub enum ProtoType {
6661
/// The URL uses a UDP transport.
62+
#[default]
6763
Udp,
6864

6965
/// The URL uses a TCP transport.
@@ -72,12 +68,6 @@ pub enum ProtoType {
7268
Unknown,
7369
}
7470

75-
impl Default for ProtoType {
76-
fn default() -> Self {
77-
Self::Udp
78-
}
79-
}
80-
8171
// defines a procedure for creating a new ProtoType from a raw
8272
// string naming the transport protocol type.
8373
impl From<&str> for ProtoType {

webrtc/src/api/media_engine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl MediaEngine {
105105
/// register_default_codecs is not safe for concurrent use.
106106
pub fn register_default_codecs(&mut self) -> Result<()> {
107107
// Default Audio Codecs
108-
for codec in vec![
108+
for codec in [
109109
RTCRtpCodecParameters {
110110
capability: RTCRtpCodecCapability {
111111
mime_type: MIME_TYPE_OPUS.to_owned(),

webrtc/src/peer_connection/peer_connection_test.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,12 @@ async fn test_receiver_reuse_during_renegotiation_issue_749() -> Result<()> {
867867
"stream_initial".to_owned(),
868868
));
869869

870-
pc_offer.add_track(Arc::clone(&video_track) as Arc<dyn TrackLocal + Send + Sync>).await?;
871-
pc_offer.add_track(Arc::clone(&audio_track) as Arc<dyn TrackLocal + Send + Sync>).await?;
870+
pc_offer
871+
.add_track(Arc::clone(&video_track) as Arc<dyn TrackLocal + Send + Sync>)
872+
.await?;
873+
pc_offer
874+
.add_track(Arc::clone(&audio_track) as Arc<dyn TrackLocal + Send + Sync>)
875+
.await?;
872876

873877
// Step 2: Perform initial negotiation
874878
signal_pair(&mut pc_offer, &mut pc_answer).await?;
@@ -921,7 +925,9 @@ async fn test_receiver_reuse_during_renegotiation_issue_749() -> Result<()> {
921925
"stream_new".to_owned(),
922926
));
923927

924-
pc_offer.add_track(new_video_track as Arc<dyn TrackLocal + Send + Sync>).await?;
928+
pc_offer
929+
.add_track(new_video_track as Arc<dyn TrackLocal + Send + Sync>)
930+
.await?;
925931

926932
// Step 5: Perform renegotiation
927933
let reoffer = pc_offer.create_offer(None).await?;

0 commit comments

Comments
 (0)