versatica / mediasoup

Cutting Edge WebRTC Video Conferencing
https://mediasoup.org
ISC License
6.18k stars 1.12k forks source link

ListenInfo: Add transport socket flags #1291

Closed ibc closed 8 months ago

ibc commented 9 months ago

Details

TODO

ibc commented 9 months ago

Rust hates me:

error[E0204]: the trait `std::marker::Copy` cannot be implemented for this type
  --> rust/src/data_structures.rs:52:17
   |
52 | #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)]
   |                 ^^^^
...
67 |     pub flags: Option<Vec<SocketFlag>>,
   |     ---------------------------------- this field does not implement `std::marker::Copy`
   |
note: the `std::marker::Copy` impl for `std::option::Option<std::vec::Vec<data_structures::SocketFlag>>` requires that `std::vec::Vec<data_structures::SocketFlag>: std::marker::Copy`
  --> rust/src/data_structures.rs:67:16
   |
67 |     pub flags: Option<Vec<SocketFlag>>,
   |                ^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0204`.
nazar-pc commented 9 months ago

Rust hates me:

It helps you write bug-free code. In this case Copy can no longer be derived because Vec is heap-allocated data structure rather than a bag of bytes. Remove Copy from derive if you have to use a vector there.

ibc commented 9 months ago

It helps you write bug-free code. In this case Copy can no longer be derived because Vec is heap-allocated data structure rather than a bag of bytes. Remove Copy from derive if you have to use a vector there.

And what are the consequences of removing Copy from derive in that struct?

nazar-pc commented 9 months ago

And what are the consequences of removing Copy from derive in that struct?

You'll have to call .clone() on it rather than value being implicitly copied (like it happens with u8 for example). Clone typically means there is some side effect of the cloning, in case of vector the biggest side effect is allocation of memory.

ibc commented 9 months ago

@jmillan I've pushed this: https://github.com/versatica/mediasoup/pull/1291/commits/a1405e23abee5dcfd13199d87c767fe5c331f4b6

threema-lenny commented 5 months ago

I stumbled upon this. It would have been nice to mention the switch from setting UV_UDP_IPV6ONLY by default to make it optional and user-supplied in the changelog as it was effectively a breaking change in behaviour.

ibc commented 5 months ago

I stumbled upon this. It would have been nice to mention the switch from setting UV_UDP_IPV6ONLY by default to make it optional and user-supplied in the changelog as it was effectively a breaking change in behaviour.

True. I've updated the PR description and added a note in the CHANGELOG file: https://github.com/versatica/mediasoup/commit/2854761ff1dc984d1d3f31cbf216319c085b2e12