Skip to content

Commit 8541b83

Browse files
authored
feat(request_response, dns): remove async_trait
This PR refactors `request_response::Codec` to simplify its implementation and remove the need for `#[async_trait::async_trait]`. It also refactors `libp2p-dns::Resolver` to not use `async_trait` (async trait method has been stablized in [1.75.0](https://releases.rs/docs/1.75.0/#language) and MSRV of libp2p is 1.83.0) Pull-Request: libp2p#6292.
1 parent da3df26 commit 8541b83

File tree

17 files changed

+57
-48
lines changed

17 files changed

+57
-48
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ edition = "2021"
7676
[workspace.dependencies]
7777
libp2p = { version = "0.56.1", path = "libp2p" }
7878
libp2p-allow-block-list = { version = "0.6.0", path = "misc/allow-block-list" }
79-
libp2p-autonat = { version = "0.15.0", path = "protocols/autonat" }
79+
libp2p-autonat = { version = "0.16.0", path = "protocols/autonat" }
8080
libp2p-connection-limits = { version = "0.6.0", path = "misc/connection-limits" }
8181
libp2p-core = { version = "0.43.2", path = "core" }
8282
libp2p-dcutr = { version = "0.14.1", path = "protocols/dcutr" }
83-
libp2p-dns = { version = "0.44.0", path = "transports/dns" }
83+
libp2p-dns = { version = "0.45.0", path = "transports/dns" }
8484
libp2p-floodsub = { version = "0.47.0", path = "protocols/floodsub" }
8585
libp2p-gossipsub = { version = "0.50.0", path = "protocols/gossipsub" }
8686
libp2p-identify = { version = "0.47.0", path = "protocols/identify" }
@@ -98,8 +98,8 @@ libp2p-plaintext = { version = "0.43.0", path = "transports/plaintext" }
9898
libp2p-pnet = { version = "0.26.0", path = "transports/pnet" }
9999
libp2p-quic = { version = "0.13.0", path = "transports/quic" }
100100
libp2p-relay = { version = "0.21.1", path = "protocols/relay" }
101-
libp2p-rendezvous = { version = "0.17.0", path = "protocols/rendezvous" }
102-
libp2p-request-response = { version = "0.29.0", path = "protocols/request-response" }
101+
libp2p-rendezvous = { version = "0.18.0", path = "protocols/rendezvous" }
102+
libp2p-request-response = { version = "0.30.0", path = "protocols/request-response" }
103103
libp2p-server = { version = "0.12.7", path = "misc/server" }
104104
libp2p-stream = { version = "0.4.0-alpha", path = "protocols/stream" }
105105
libp2p-swarm = { version = "0.47.1", path = "swarm" }

protocols/autonat/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.16.0
2+
3+
- refactor: `Codec` no longer requires `#[async_trait]`
4+
See [PR 6292](https://github.com/libp2p/rust-libp2p/pull/6292)
5+
16
## 0.15.0
27

38
- Fix infinity loop on wrong `nonce` when performing `dial_back`.

protocols/autonat/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-autonat"
33
edition.workspace = true
44
rust-version = { workspace = true }
55
description = "NAT and firewall detection for libp2p"
6-
version = "0.15.0"
6+
version = "0.16.0"
77
authors = [
88
"David Craven <david@craven.ch>",
99
"Elena Frank <elena.frank@protonmail.com>",
@@ -16,7 +16,6 @@ categories = ["network-programming", "asynchronous"]
1616

1717

1818
[dependencies]
19-
async-trait = { version = "0.1", optional = true }
2019
asynchronous-codec = { workspace = true }
2120
either = { version = "1.9.0", optional = true }
2221
futures = { workspace = true }
@@ -43,7 +42,7 @@ libp2p-swarm = { workspace = true, features = ["macros"] }
4342

4443
[features]
4544
default = ["v1", "v2"]
46-
v1 = ["dep:libp2p-request-response", "dep:web-time", "dep:async-trait"]
45+
v1 = ["dep:libp2p-request-response", "dep:web-time"]
4746
v2 = ["dep:either", "dep:futures-bounded", "dep:thiserror", "dep:rand_core"]
4847

4948
# Passing arguments to the docsrs builder in order to properly document cfg's.

protocols/autonat/src/v1/protocol.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
use std::io;
2222

23-
use async_trait::async_trait;
2423
use asynchronous_codec::{FramedRead, FramedWrite};
2524
use futures::{
2625
io::{AsyncRead, AsyncWrite},
@@ -39,7 +38,6 @@ pub const DEFAULT_PROTOCOL_NAME: StreamProtocol = StreamProtocol::new("/libp2p/a
3938
#[derive(Clone)]
4039
pub struct AutoNatCodec;
4140

42-
#[async_trait]
4341
impl request_response::Codec for AutoNatCodec {
4442
type Protocol = StreamProtocol;
4543
type Request = DialRequest;

protocols/rendezvous/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.18.0
2+
3+
- refactor: `Codec` no longer requires `#[async_trait]`
4+
See [PR 6292](https://github.com/libp2p/rust-libp2p/pull/6292)
5+
16
## 0.17.0
27

38
- Emit `ToSwarm::NewExternalAddrOfPeer` for newly discovered peers.

protocols/rendezvous/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-rendezvous"
33
edition.workspace = true
44
rust-version = { workspace = true }
55
description = "Rendezvous protocol for libp2p"
6-
version = "0.17.0"
6+
version = "0.18.0"
77
authors = ["The COMIT guys <hello@comit.network>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"
@@ -12,7 +12,6 @@ categories = ["network-programming", "asynchronous"]
1212

1313
[dependencies]
1414
asynchronous-codec = { workspace = true }
15-
async-trait = "0.1"
1615
bimap = "0.6.3"
1716
futures = { workspace = true, features = ["std"] }
1817
futures-timer = "3.0.3"

protocols/rendezvous/src/codec.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
use std::{fmt, io};
2222

23-
use async_trait::async_trait;
2423
use asynchronous_codec::{BytesMut, Decoder, Encoder, FramedRead, FramedWrite};
2524
use futures::{AsyncRead, AsyncWrite, SinkExt, StreamExt};
2625
use libp2p_core::{peer_record, signed_envelope, PeerRecord, SignedEnvelope};
@@ -241,7 +240,6 @@ impl Decoder for Codec {
241240
#[derive(Clone, Default)]
242241
pub struct Codec {}
243242

244-
#[async_trait]
245243
impl libp2p_request_response::Codec for Codec {
246244
type Protocol = StreamProtocol;
247245
type Request = Message;

protocols/request-response/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.30.0
2+
3+
- refactor: `Codec` no longer requires `#[async_trait]`
4+
See [PR 6292](https://github.com/libp2p/rust-libp2p/pull/6292)
5+
16
## 0.29.0
27

38
- fix: public cbor/json codec module

protocols/request-response/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ name = "libp2p-request-response"
33
edition.workspace = true
44
rust-version = { workspace = true }
55
description = "Generic Request/Response Protocols"
6-
version = "0.29.0"
6+
version = "0.30.0"
77
authors = ["Parity Technologies <admin@parity.io>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"
1010
keywords = ["peer-to-peer", "libp2p", "networking"]
1111
categories = ["network-programming", "asynchronous"]
1212

1313
[dependencies]
14-
async-trait = "0.1"
1514
cbor4ii = { version = "0.3.2", features = ["serde1", "use_std"], optional = true }
1615
futures = { workspace = true }
1716
libp2p-core = { workspace = true }

0 commit comments

Comments
 (0)