Skip to content

Commit ce91c1c

Browse files
chore: apply clippy lints to public API
By default, clippy doesn't suggest changes if it would break the public API. Whilst a sensible default, it makes us miss certain opportunities to follow conventions correctly. When a new lint is added, we can always temporarily allow it and make a change in the next breaking release but I think it is better to be aware of the lint than having it automatically silenced. Pull-Request: libp2p#4653.
1 parent 7c6f75e commit ce91c1c

File tree

16 files changed

+47
-20
lines changed

16 files changed

+47
-20
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ libp2p-dns = { version = "0.40.1", path = "transports/dns" }
8383
libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" }
8484
libp2p-gossipsub = { version = "0.45.2", path = "protocols/gossipsub" }
8585
libp2p-identify = { version = "0.43.1", path = "protocols/identify" }
86-
libp2p-identity = { version = "0.2.5" }
86+
libp2p-identity = { version = "0.2.6" }
8787
libp2p-kad = { version = "0.44.6", path = "protocols/kad" }
8888
libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" }
8989
libp2p-memory-connection-limits = { version = "0.1.0", path = "misc/memory-connection-limits" }
@@ -94,7 +94,7 @@ libp2p-noise = { version = "0.43.2", path = "transports/noise" }
9494
libp2p-perf = { version = "0.2.0", path = "protocols/perf" }
9595
libp2p-ping = { version = "0.43.1", path = "protocols/ping" }
9696
libp2p-plaintext = { version = "0.40.1", path = "transports/plaintext" }
97-
libp2p-pnet = { version = "0.23.0", path = "transports/pnet" }
97+
libp2p-pnet = { version = "0.23.1", path = "transports/pnet" }
9898
libp2p-quic = { version = "0.9.3", path = "transports/quic" }
9999
libp2p-relay = { version = "0.16.2", path = "protocols/relay" }
100100
libp2p-rendezvous = { version = "0.13.1", path = "protocols/rendezvous" }
@@ -110,7 +110,7 @@ libp2p-uds = { version = "0.39.0", path = "transports/uds" }
110110
libp2p-wasm-ext = { version = "0.40.0", path = "transports/wasm-ext" }
111111
libp2p-webrtc = { version = "0.6.1-alpha", path = "transports/webrtc" }
112112
libp2p-webrtc-utils = { version = "0.1.0", path = "misc/webrtc-utils" }
113-
libp2p-webrtc-websys = { version = "0.1.0-alpha", path = "transports/webrtc-websys" }
113+
libp2p-webrtc-websys = { version = "0.2.0-alpha", path = "transports/webrtc-websys" }
114114
libp2p-websocket = { version = "0.42.1", path = "transports/websocket" }
115115
libp2p-websocket-websys = { version = "0.2.0", path = "transports/websocket-websys" }
116116
libp2p-webtransport-websys = { version = "0.1.0", path = "transports/webtransport-websys" }

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
disallowed-methods = [
22
{ path = "futures::channel::mpsc::unbounded", reason = "does not enforce backpressure" },
33
]
4+
avoid-breaking-exported-api = false

identity/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.6
2+
3+
- Make `PeerId::to_bytes` and `PeerId::to_base58` take `self` by value to follow Rust convention of `Copy` types.
4+
See [PR 4653](https://github.com/libp2p/rust-libp2p/pull/4653).
5+
16
## 0.2.5
27

38
- Fix usage of HKDF within `Keypair::derive_secret`.

identity/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libp2p-identity"
3-
version = "0.2.5"
3+
version = "0.2.6"
44
edition = "2021"
55
description = "Data structures and algorithms for identifying peers in libp2p."
66
rust-version = { workspace = true }

identity/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ pub use keypair::{Keypair, PublicKey};
114114
#[cfg(feature = "peerid")]
115115
pub use peer_id::{ParseError, PeerId};
116116

117-
#[derive(Debug, PartialEq, Eq)]
118117
/// The type of key a `KeyPair` is holding.
118+
#[derive(Debug, PartialEq, Eq)]
119+
#[allow(clippy::upper_case_acronyms)]
119120
pub enum KeyType {
120121
Ed25519,
121122
RSA,

identity/src/peer_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ impl PeerId {
109109
}
110110

111111
/// Returns a raw bytes representation of this `PeerId`.
112-
pub fn to_bytes(&self) -> Vec<u8> {
112+
pub fn to_bytes(self) -> Vec<u8> {
113113
self.multihash.to_bytes()
114114
}
115115

116116
/// Returns a base-58 encoded string of this `PeerId`.
117-
pub fn to_base58(&self) -> String {
117+
pub fn to_base58(self) -> String {
118118
bs58::encode(self.to_bytes()).into_string()
119119
}
120120
}

protocols/gossipsub/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
- Deprecate `gossipsub::Config::idle_timeout` in favor of `SwarmBuilder::idle_connection_timeout`.
44
See [PR 4648].
55

6+
<!-- Interal changes:
7+
8+
- Allow new clippy lint.
9+
10+
-->
11+
612
[PR 4648]: (https://github.com/libp2p/rust-libp2p/pull/4648)
713

814
<!-- Internal changes

protocols/gossipsub/src/behaviour.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,7 @@ where
27872787

27882788
let signature = {
27892789
let message = proto::Message {
2790-
from: Some(author.clone().to_bytes()),
2790+
from: Some(author.to_bytes()),
27912791
data: Some(data.clone()),
27922792
seqno: Some(sequence_number.to_be_bytes().to_vec()),
27932793
topic: topic.clone().into_string(),

transports/pnet/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.23.1 - unreleased
2+
3+
<!-- Interal changes:
4+
5+
- Allow new clippy lint.
6+
7+
-->
8+
19
## 0.23.0
210

311
- Raise MSRV to 1.65.

transports/pnet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-pnet"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "Private swarm support for libp2p"
6-
version = "0.23.0"
6+
version = "0.23.1"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

transports/pnet/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ impl fmt::Display for Fingerprint {
159159

160160
/// Error when parsing a PreSharedKey
161161
#[derive(Clone, Debug, PartialEq, Eq)]
162+
#[allow(clippy::enum_variant_names)] // Maybe fix at some stage, not important now.
162163
pub enum KeyParseError {
163164
/// file does not have the expected structure
164165
InvalidKeyFile,

transports/webrtc-websys/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.0-alpha - unreleased
2+
3+
- Rename `Error::JsError` to `Error::Js`.
4+
See [PR 4653](https://github.com/libp2p/rust-libp2p/pull/4653)
5+
16
## 0.1.0-alpha
27

38
- Initial alpha release.

transports/webrtc-websys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT"
88
name = "libp2p-webrtc-websys"
99
repository = "https://github.com/libp2p/rust-libp2p"
1010
rust-version = { workspace = true }
11-
version = "0.1.0-alpha"
11+
version = "0.2.0-alpha"
1212
publish = true
1313

1414
[dependencies]

transports/webrtc-websys/src/connection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ impl RtcPeerConnection {
252252
let sdp = &self
253253
.inner
254254
.local_description()
255-
.ok_or_else(|| Error::JsError("No local description".to_string()))?
255+
.ok_or_else(|| Error::Js("No local description".to_string()))?
256256
.sdp();
257257

258-
let fingerprint = parse_fingerprint(sdp)
259-
.ok_or_else(|| Error::JsError("No fingerprint in SDP".to_string()))?;
258+
let fingerprint =
259+
parse_fingerprint(sdp).ok_or_else(|| Error::Js("No fingerprint in SDP".to_string()))?;
260260

261261
Ok(fingerprint)
262262
}

transports/webrtc-websys/src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub enum Error {
88
InvalidMultiaddr(&'static str),
99

1010
#[error("JavaScript error: {0}")]
11-
JsError(String),
11+
Js(String),
1212

1313
#[error("JavaScript typecasting failed")]
1414
JsCastFailed,
@@ -34,7 +34,7 @@ impl Error {
3434
"Unknown error".to_string()
3535
};
3636

37-
Error::JsError(s)
37+
Error::Js(s)
3838
}
3939
}
4040

@@ -46,12 +46,12 @@ impl std::convert::From<wasm_bindgen::JsValue> for Error {
4646

4747
impl From<String> for Error {
4848
fn from(value: String) -> Self {
49-
Error::JsError(value)
49+
Error::Js(value)
5050
}
5151
}
5252

5353
impl From<std::io::Error> for Error {
5454
fn from(value: std::io::Error) -> Self {
55-
Error::JsError(value.to_string())
55+
Error::Js(value.to_string())
5656
}
5757
}

0 commit comments

Comments
 (0)