Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change __Nonexhaustive to __Invalid and update web-sys #5569

Merged
merged 11 commits into from
Aug 27, 2024
54 changes: 33 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ libp2p-uds = { version = "0.41.0", path = "transports/uds" }
libp2p-upnp = { version = "0.3.0", path = "protocols/upnp" }
libp2p-webrtc = { version = "0.8.0-alpha", path = "transports/webrtc" }
libp2p-webrtc-utils = { version = "0.3.0", path = "misc/webrtc-utils" }
libp2p-webrtc-websys = { version = "0.4.0-alpha", path = "transports/webrtc-websys" }
libp2p-webrtc-websys = { version = "0.4.0-alpha.2", path = "transports/webrtc-websys" }
libp2p-websocket = { version = "0.44.0", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.4.0", path = "transports/websocket-websys" }
libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" }
Expand Down
5 changes: 5 additions & 0 deletions transports/webrtc-websys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.0-alpha.2

- Bump version of web-sys and update `__Nonexhaustive` to `__Invalid`.
See [PR 5569](https://github.com/libp2p/rust-libp2p/pull/5569)

## 0.4.0-alpha

- Implement refactored `Transport`.
Expand Down
4 changes: 2 additions & 2 deletions transports/webrtc-websys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT"
name = "libp2p-webrtc-websys"
repository = "https://github.com/libp2p/rust-libp2p"
rust-version = { workspace = true }
version = "0.4.0-alpha"
version = "0.4.0-alpha.2"
publish = true

[dependencies]
Expand All @@ -25,7 +25,7 @@ thiserror = "1"
tracing = { workspace = true }
wasm-bindgen = { version = "0.2.90" }
wasm-bindgen-futures = { version = "0.4.42" }
web-sys = { version = "0.3.69", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] }
web-sys = { version = "0.3.70", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] }

[lints]
workspace = true
9 changes: 5 additions & 4 deletions transports/webrtc-websys/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ impl RtcPeerConnection {

let certificate = JsFuture::from(certificate_promise).await?;

let mut config = RtcConfiguration::default();
let config = RtcConfiguration::default();
// wrap certificate in a js Array first before adding it to the config object
let certificate_arr = js_sys::Array::new();
certificate_arr.push(&certificate);
config.certificates(&certificate_arr);
config.set_certificates(&certificate_arr);

let inner = web_sys::RtcPeerConnection::new_with_configuration(&config)?;

Expand All @@ -214,8 +214,9 @@ impl RtcPeerConnection {

let dc = match negotiated {
true => {
let mut options = RtcDataChannelInit::new();
options.negotiated(true).id(0); // id is only ever set to zero when negotiated is true
let options = RtcDataChannelInit::new();
options.set_negotiated(true);
options.set_id(0); // id is only ever set to zero when negotiated is true

self.inner
.create_data_channel_with_data_channel_dict(LABEL, &options)
Expand Down
8 changes: 4 additions & 4 deletions transports/webrtc-websys/src/sdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub(crate) fn answer(
server_fingerprint: Fingerprint,
client_ufrag: &str,
) -> RtcSessionDescriptionInit {
let mut answer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Answer);
answer_obj.sdp(&libp2p_webrtc_utils::sdp::answer(
let answer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Answer);
answer_obj.set_sdp(&libp2p_webrtc_utils::sdp::answer(
addr,
server_fingerprint,
client_ufrag,
Expand Down Expand Up @@ -48,8 +48,8 @@ pub(crate) fn offer(offer: String, client_ufrag: &str) -> RtcSessionDescriptionI

tracing::trace!(offer=%munged_sdp_offer, "Created SDP offer");

let mut offer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Offer);
offer_obj.sdp(&munged_sdp_offer);
let offer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Offer);
offer_obj.set_sdp(&munged_sdp_offer);

offer_obj
}
3 changes: 2 additions & 1 deletion transports/webrtc-websys/src/stream/poll_data_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ impl PollDataChannel {
RtcDataChannelState::Closing | RtcDataChannelState::Closed => {
return Poll::Ready(Err(io::ErrorKind::BrokenPipe.into()))
}
RtcDataChannelState::Open | RtcDataChannelState::__Nonexhaustive => {}
RtcDataChannelState::Open | RtcDataChannelState::__Invalid => {}
_ => {}
}

if self.overloaded.load(Ordering::SeqCst) {
Expand Down
2 changes: 2 additions & 0 deletions transports/webtransport-websys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- Implement refactored `Transport`.
See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568)
- Bump version of web-sys and wasm-bindgen.
See [PR 5569](https://github.com/libp2p/rust-libp2p/pull/5569)

## 0.3.0

Expand Down
8 changes: 4 additions & 4 deletions transports/webtransport-websys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"]

[dependencies]
futures = { workspace = true }
js-sys = "0.3.69"
js-sys = "0.3.70"
libp2p-core = { workspace = true }
libp2p-identity = { workspace = true }
libp2p-noise = { workspace = true }
Expand All @@ -24,9 +24,9 @@ multihash = { workspace = true }
send_wrapper = { version = "0.6.0", features = ["futures"] }
thiserror = "1.0.61"
tracing = { workspace = true }
wasm-bindgen = "0.2.90"
wasm-bindgen-futures = "0.4.42"
web-sys = { version = "0.3.69", features = [
wasm-bindgen = "0.2.93"
wasm-bindgen-futures = "0.4.43"
web-sys = { version = "0.3.70", features = [
"ReadableStreamDefaultReader",
"WebTransport",
"WebTransportBidirectionalStream",
Expand Down
8 changes: 4 additions & 4 deletions wasm-tests/webtransport-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ libp2p-noise = { workspace = true }
libp2p-webtransport-websys = { workspace = true }
multiaddr = { workspace = true }
multihash = { workspace = true }
wasm-bindgen = "0.2.90"
wasm-bindgen-futures = "0.4.42"
wasm-bindgen-test = "0.3.42"
web-sys = { version = "0.3.69", features = ["Response", "Window"] }
wasm-bindgen = "0.2.93"
wasm-bindgen-futures = "0.4.43"
wasm-bindgen-test = "0.3.43"
web-sys = { version = "0.3.70", features = ["Response", "Window"] }

[lints]
workspace = true
Loading