Skip to content

Commit c89444f

Browse files
authored
chore(uds): Renamed UDS Confing to follow re-export convention
From #2217. Renaming UDS Config symbol from `UdsConfig` in the doc comment and from `TokioUdsConfig`, for better referencing when re-exported. Left deprecated alias for backward compatibility. Pull-Request: #6190.
1 parent b3d3167 commit c89444f

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-s
107107
libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" }
108108
libp2p-tcp = { version = "0.44.0", path = "transports/tcp" }
109109
libp2p-tls = { version = "0.6.2", path = "transports/tls" }
110-
libp2p-uds = { version = "0.43.0", path = "transports/uds" }
110+
libp2p-uds = { version = "0.43.1", path = "transports/uds" }
111111
libp2p-upnp = { version = "0.6.0", path = "protocols/upnp" }
112112
libp2p-webrtc = { version = "0.9.0-alpha.2", path = "transports/webrtc" }
113113
libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" }

transports/uds/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.43.1
2+
3+
- Rename Config to match naming convention in [discussion 2174](https://github.com/libp2p/rust-libp2p/discussions/2174).
4+
See [PR 6190](https://github.com/libp2p/rust-libp2p/pull/6190).
5+
16
## 0.43.0
27

38
- Remove `async-std` support.

transports/uds/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-uds"
33
edition.workspace = true
44
rust-version = { workspace = true }
55
description = "Unix domain sockets transport for libp2p"
6-
version = "0.43.0"
6+
version = "0.43.1"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

transports/uds/src/lib.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
//!
2727
//! # Usage
2828
//!
29-
//! The `UdsConfig` transport supports multiaddresses of the form `/unix//tmp/foo`.
29+
//! The `Config` transport supports multiaddresses of the form `/unix//tmp/foo`.
3030
//!
31-
//! The `UdsConfig` structs implements the `Transport` trait of the `core` library. See the
31+
//! The `Config` structs implements the `Transport` trait of the `core` library. See the
3232
//! documentation of `core` and of libp2p in general to learn how to use the `Transport` trait.
3333
3434
#![cfg(all(unix, not(target_os = "emscripten"), feature = "tokio"))]
@@ -62,28 +62,28 @@ pub type Listener<T> = BoxStream<
6262
>;
6363

6464
macro_rules! codegen {
65-
($feature_name:expr, $uds_config:ident, $build_listener:expr, $unix_stream:ty, $($mut_or_not:tt)*) => {
65+
($feature_name:expr, $config:ident, $build_listener:expr, $unix_stream:ty, $($mut_or_not:tt)*) => {
6666
/// Represents the configuration for a Unix domain sockets transport capability for libp2p.
67-
pub struct $uds_config {
67+
pub struct $config {
6868
listeners: VecDeque<(ListenerId, Listener<Self>)>,
6969
}
7070

71-
impl $uds_config {
71+
impl $config {
7272
/// Creates a new configuration object for Unix domain sockets.
73-
pub fn new() -> $uds_config {
74-
$uds_config {
73+
pub fn new() -> $config {
74+
$config {
7575
listeners: VecDeque::new(),
7676
}
7777
}
7878
}
7979

80-
impl Default for $uds_config {
80+
impl Default for $config {
8181
fn default() -> Self {
8282
Self::new()
8383
}
8484
}
8585

86-
impl Transport for $uds_config {
86+
impl Transport for $config {
8787
type Output = $unix_stream;
8888
type Error = io::Error;
8989
type ListenerUpgrade = Ready<Result<Self::Output, Self::Error>>;
@@ -204,11 +204,16 @@ macro_rules! codegen {
204204
#[cfg(feature = "tokio")]
205205
codegen!(
206206
"tokio",
207-
TokioUdsConfig,
207+
Config,
208208
|addr| async move { tokio::net::UnixListener::bind(&addr) },
209209
tokio::net::UnixStream,
210210
);
211211

212+
// Deprecated type alias for backward compatibility
213+
#[cfg(feature = "tokio")]
214+
#[deprecated(since = "0.43.1", note = "Use `libp2p::uds::Config` instead")]
215+
pub type TokioUdsConfig = Config;
216+
212217
/// Turns a `Multiaddr` containing a single `Unix` component into a path.
213218
///
214219
/// Also returns an error if the path is not absolute, as we don't want to dial/listen on relative
@@ -243,7 +248,8 @@ mod tests {
243248
};
244249
use tokio::io::{AsyncReadExt, AsyncWriteExt};
245250

246-
use super::{multiaddr_to_path, TokioUdsConfig};
251+
use super::multiaddr_to_path;
252+
use crate::Config;
247253

248254
#[test]
249255
fn multiaddr_to_path_conversion() {
@@ -272,7 +278,7 @@ mod tests {
272278
let (tx, rx) = oneshot::channel();
273279

274280
let listener = async move {
275-
let mut transport = TokioUdsConfig::new().boxed();
281+
let mut transport = Config::new().boxed();
276282
transport.listen_on(ListenerId::next(), addr).unwrap();
277283

278284
let listen_addr = transport
@@ -296,7 +302,7 @@ mod tests {
296302
};
297303

298304
let dialer = async move {
299-
let mut uds = TokioUdsConfig::new();
305+
let mut uds = Config::new();
300306
let addr = rx.await.unwrap();
301307
let mut socket = uds
302308
.dial(
@@ -318,7 +324,7 @@ mod tests {
318324
#[test]
319325
#[ignore] // TODO: for the moment unix addresses fail to parse
320326
fn larger_addr_denied() {
321-
let mut uds = TokioUdsConfig::new();
327+
let mut uds = Config::new();
322328

323329
let addr = "/unix//foo/bar".parse::<Multiaddr>().unwrap();
324330
assert!(uds.listen_on(ListenerId::next(), addr).is_err());

0 commit comments

Comments
 (0)