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
29 changes: 15 additions & 14 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion 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`
jxs marked this conversation as resolved.
Show resolved Hide resolved
See [PR 5569](https://github.com/libp2p/rust-libp2p/pull/5569)

## 0.4.0-alpha

- Implement refactored `Transport`.
Expand All @@ -8,7 +13,7 @@
- Bump version in order to publish a new version dependent on latest `libp2p-core`.
See [PR 4959](https://github.com/libp2p/rust-libp2p/pull/4959).
- Remove `libp2p_noise` from the public API.
See [PR 4969](https://github.com/libp2p/rust-libp2p/pull/4969).
See [PR 4969](https://github.com/libp2p/rust-libp2p/pull/4969).
dariusc93 marked this conversation as resolved.
Show resolved Hide resolved

## 0.2.0-alpha

Expand Down
2 changes: 1 addition & 1 deletion transports/webrtc-websys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading