Skip to content

Commit ce3908f

Browse files
authored
chore(websocket): change name convention
From #2217 , Changing `WsConfig` to `Config` Pull-Request: #5873.
1 parent b1afe88 commit ce3908f

File tree

8 files changed

+32
-23
lines changed

8 files changed

+32
-23
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
@@ -109,7 +109,7 @@ libp2p-upnp = { version = "0.4.0", path = "protocols/upnp" }
109109
libp2p-webrtc = { version = "0.9.0-alpha", path = "transports/webrtc" }
110110
libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" }
111111
libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" }
112-
libp2p-websocket = { version = "0.45.0", path = "transports/websocket" }
112+
libp2p-websocket = { version = "0.45.1", path = "transports/websocket" }
113113
libp2p-websocket-websys = { version = "0.5.0", path = "transports/websocket-websys" }
114114
libp2p-webtransport-websys = { version = "0.5.0", path = "transports/webtransport-websys" }
115115
libp2p-yamux = { version = "0.47.0", path = "muxers/yamux" }

libp2p/src/builder/phase/websocket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ macro_rules! impl_websocket_builder {
9393
{
9494
let security_upgrade = security_upgrade.into_security_upgrade(&self.keypair)
9595
.map_err(WebsocketErrorInner::SecurityUpgrade)?;
96-
let websocket_transport = libp2p_websocket::WsConfig::new(
96+
let websocket_transport = libp2p_websocket::Config::new(
9797
$dnsTcp.await.map_err(WebsocketErrorInner::Dns)?,
9898
)
9999
.upgrade(libp2p_core::upgrade::Version::V1Lazy)

transports/pnet/tests/smoke.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async fn can_establish_connection_tcp() {
3030
#[tokio::test]
3131
async fn can_establish_connection_websocket() {
3232
can_establish_connection_inner_with_timeout(
33-
|| libp2p_websocket::WsConfig::new(libp2p_tcp::tokio::Transport::default()),
33+
|| libp2p_websocket::Config::new(libp2p_tcp::tokio::Transport::default()),
3434
"/ip4/127.0.0.1/tcp/0/ws".parse().unwrap(),
3535
)
3636
.await

transports/websocket/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.45.1
2+
- Rename types to match naming convention in [discussion 2174](https://github.com/libp2p/rust-libp2p/discussions/2174).
3+
See [PR 5873](https://github.com/libp2p/rust-libp2p/pull/5873).
4+
15
## 0.45.0
26

37
- fix: Return `Error::InvalidMultiaddr` when dialed to a `/dnsaddr` address

transports/websocket/Cargo.toml

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

transports/websocket/src/framed.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ const MAX_DATA_SIZE: usize = 256 * 1024 * 1024;
5151

5252
/// A Websocket transport whose output type is a [`Stream`] and [`Sink`] of
5353
/// frame payloads which does not implement [`AsyncRead`] or
54-
/// [`AsyncWrite`]. See [`crate::WsConfig`] if you require the latter.
54+
/// [`AsyncWrite`]. See [`crate::Config`] if you require the latter.
55+
#[deprecated = "Use `Config` instead"]
56+
pub type WsConfig<T> = Config<T>;
57+
5558
#[derive(Debug)]
56-
pub struct WsConfig<T> {
59+
pub struct Config<T> {
5760
transport: Arc<Mutex<T>>,
5861
max_data_size: usize,
5962
tls_config: tls::Config,
@@ -62,13 +65,13 @@ pub struct WsConfig<T> {
6265
listener_protos: HashMap<ListenerId, WsListenProto<'static>>,
6366
}
6467

65-
impl<T> WsConfig<T>
68+
impl<T> Config<T>
6669
where
6770
T: Send,
6871
{
6972
/// Create a new websocket transport based on another transport.
7073
pub fn new(transport: T) -> Self {
71-
WsConfig {
74+
Config {
7275
transport: Arc::new(Mutex::new(transport)),
7376
max_data_size: MAX_DATA_SIZE,
7477
tls_config: tls::Config::client(),
@@ -108,7 +111,7 @@ where
108111

109112
type TlsOrPlain<T> = future::Either<future::Either<client::TlsStream<T>, server::TlsStream<T>>, T>;
110113

111-
impl<T> Transport for WsConfig<T>
114+
impl<T> Transport for Config<T>
112115
where
113116
T: Transport + Send + Unpin + 'static,
114117
T::Error: Send + 'static,
@@ -242,7 +245,7 @@ where
242245
}
243246
}
244247

245-
impl<T> WsConfig<T>
248+
impl<T> Config<T>
246249
where
247250
T: Transport + Send + Unpin + 'static,
248251
T::Error: Send + 'static,

transports/websocket/src/lib.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use rw_stream_sink::RwStreamSink;
7676
/// # #[async_std::main]
7777
/// # async fn main() {
7878
///
79-
/// let mut transport = websocket::WsConfig::new(
79+
/// let mut transport = websocket::Config::new(
8080
/// dns::async_std::Transport::system(tcp::async_io::Transport::new(tcp::Config::default()))
8181
/// .await
8282
/// .unwrap(),
@@ -117,7 +117,7 @@ use rw_stream_sink::RwStreamSink;
117117
/// # async fn main() {
118118
///
119119
/// let mut transport =
120-
/// websocket::WsConfig::new(tcp::async_io::Transport::new(tcp::Config::default()));
120+
/// websocket::Config::new(tcp::async_io::Transport::new(tcp::Config::default()));
121121
///
122122
/// let id = transport
123123
/// .listen_on(
@@ -134,16 +134,19 @@ use rw_stream_sink::RwStreamSink;
134134
///
135135
/// # }
136136
/// ```
137+
#[deprecated = "Use `Config` instead"]
138+
pub type WsConfig<Transport> = Config<Transport>;
139+
137140
#[derive(Debug)]
138-
pub struct WsConfig<T: Transport>
141+
pub struct Config<T: Transport>
139142
where
140143
T: Transport,
141144
T::Output: AsyncRead + AsyncWrite + Send + Unpin + 'static,
142145
{
143-
transport: libp2p_core::transport::map::Map<framed::WsConfig<T>, WrapperFn<T::Output>>,
146+
transport: libp2p_core::transport::map::Map<framed::Config<T>, WrapperFn<T::Output>>,
144147
}
145148

146-
impl<T: Transport> WsConfig<T>
149+
impl<T: Transport> Config<T>
147150
where
148151
T: Transport + Send + Unpin + 'static,
149152
T::Error: Send + 'static,
@@ -161,8 +164,7 @@ where
161164
/// > the inner transport.
162165
pub fn new(transport: T) -> Self {
163166
Self {
164-
transport: framed::WsConfig::new(transport)
165-
.map(wrap_connection as WrapperFn<T::Output>),
167+
transport: framed::Config::new(transport).map(wrap_connection as WrapperFn<T::Output>),
166168
}
167169
}
168170

@@ -195,7 +197,7 @@ where
195197
}
196198
}
197199

198-
impl<T> Transport for WsConfig<T>
200+
impl<T> Transport for Config<T>
199201
where
200202
T: Transport + Send + Unpin + 'static,
201203
T::Error: Send + 'static,
@@ -236,7 +238,7 @@ where
236238
}
237239
}
238240

239-
/// Type alias corresponding to `framed::WsConfig::Dial` and `framed::WsConfig::ListenerUpgrade`.
241+
/// Type alias corresponding to `framed::Config::Dial` and `framed::Config::ListenerUpgrade`.
240242
pub type InnerFuture<T, E> = BoxFuture<'static, Result<Connection<T>, Error<E>>>;
241243

242244
/// Function type that wraps a websocket connection (see. `wrap_connection`).
@@ -310,7 +312,7 @@ mod tests {
310312
use libp2p_identity::PeerId;
311313
use libp2p_tcp as tcp;
312314

313-
use super::WsConfig;
315+
use super::Config;
314316

315317
#[test]
316318
fn dialer_connects_to_listener_ipv4() {
@@ -324,8 +326,8 @@ mod tests {
324326
futures::executor::block_on(connect(a))
325327
}
326328

327-
fn new_ws_config() -> WsConfig<tcp::async_io::Transport> {
328-
WsConfig::new(tcp::async_io::Transport::new(tcp::Config::default()))
329+
fn new_ws_config() -> Config<tcp::async_io::Transport> {
330+
Config::new(tcp::async_io::Transport::new(tcp::Config::default()))
329331
}
330332

331333
async fn connect(listen_addr: Multiaddr) {

0 commit comments

Comments
 (0)