-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
refactor: make hex_as_bytes
DRY
#1409
Conversation
- Modify `hex_as_bytes` function to return an array of bytes based on input length - Remove mutable `output` parameter in `hex_as_bytes` function - Update usage of `hex_as_bytes` function to use generic type and constant size - Simplify the conversion of `DtlsFingerprint` to `web_rtc_transport::Fingerprint` - Simplify the conversion of `web_rtc_transport::Fingerprint` to `DtlsFingerprint`
Please run |
Just a note: this will bump required Rust compiler version to one that supports const generics (which is relatively old at this point, but still) |
@ibc I ran all of those 3 commands before pushing the code. cargo fmt did not report any changes. All tests are passing. clippy does report a few things, but it is not from the code that I touched, it was already there. Should I be fixing those as well? |
Looks like CI or you are running different Rust versions. @nazar-pc, how to proceed here? AFAIU mediasoup-rust mandates a minimal Rust version but the user is free to use a major one. Does mediasoup-rust fail to build is running Rust version doesn't satisfy that minimum version declared somewhere in mediasoup files? Should we update that minimum version and match whatever version runs in CI servers? |
We have P.S. I don't mind bumping version in |
I don't understand this. |
@dhilipsiva can you run
Which matches the Rust version declared in |
If |
I just installed my toolchain using
|
If you do that in project directory you should get this:
Even though global version is different:
Make sure your brew version is not overriding rustup's version. |
Root works just fine as well |
Can confirm that I have uninstalled brew version of rust before running the cargo commands.
|
well, just bump |
Imagine I have rustc 1.72.0 in my system and Imagine I have rustc 1.79.0 in my system and |
It will not fail in either case, It'll install (if not installed already) correct version and will use correct version in the project and nothing else. |
Sorry. Should I update the version, commit and push to this branch? Is that what you meant? 😅 |
Yes |
- Update Rust toolchain channel from "1.72.0" to "1.79.0" in the [rust-toolchain.toml] file.
Update rust version in rust-toolchain.toml to 1.79.0 |
* v3: chore: Update Rust toolchain channel to version 1.79.0
Let's wait for CI. |
CI failing in |
I assume those are due to new version of Rust. |
- Update Rust toolchain channel from "1.72.0" to "1.79.0" in the [rust-toolchain.toml] file.
* v3: chore: Update Rust toolchain channel to version 1.79.0 Fix issue versatica#1374 cosmetic fix Simulcast IncreaseLayer bug when producer score is zero (versatica#1410) Update NPM deps TcpConnectionHandle.cpp: properly close handle fix asan error for new-delete-type-mismatch (versatica#1411)
cargo clippy --fix --lib -p mediasoup
- Added `#[allow(dead_code)]` attribute to `ChannelReadCallback` in `channel_read_fn.rs` - Modified and added test cases in `webrtc_server.rs` - Made changes to the `Producer` struct and related functions in `producer.rs` - Made updates to the `ScalabilityMode` implementation in `scalability_modes.rs` - Implemented various functions and callbacks in `router.rs` - Made modifications and fixes in `ortc/tests.rs` - Updated test cases in `webrtc_transport.rs` - Added attributes to struct definitions in `channel_write_fn.rs` and `consumer.rs` - Modified the code in `worker/build.rs`
@ibc @nazar-pc Most of the clippy errors were due to planus codegen. I have updated the build script to include Edit: can confirm that all clippy warnings are resolved when tested on my local. |
Well, the goal is not to get clippy to shut up by suppressing lints/commenting code without any explanation, but to actually address it. I wanted to fix it, but you have sent PR from an org rather than personal account, so I can't do that. I have pushed commit with fixes here: https://github.com/nazar-pc/mediasoup/tree/dry-DtlsFingerprint-from_fbs-fix-lints |
Oh, wow! Using Drop to silence the dead_code error is such a neat trick. :) It didn't cross my mind. |
Well, another way is to actually use named field (rather than tuple), where name starts with |
The key though is to leave an explanation why that is okay/expected |
So is this ready to merge? |
I expect one more update as described above |
Oh sincere apologies. I misunderstood. I mistakenly assumed that you will merge the changes you made on your fork. Let me do this in a couple of hours. |
- Add a new method `new` to the `ChannelReadCallback` struct in `channel_read_fn.rs` - Modify the implementation of the `ChannelReadCallback` struct to use the new method - Update the `prepare_channel_read_fn` function to use the `new` method of `ChannelReadCallback` - Add a typedef `CallbackType` to `channel_write_fn.rs` to avoid warnings - Refactor the `ChannelReadCallback` struct in `channel_write_fn.rs` to use `CallbackType` - Add a constructor method `new` to `ChannelReadCallback` in `channel_write_fn.rs` - Update the `prepare_channel_write_fn` function to use the new `ChannelReadCallback` constructor in `channel_write_fn.rs` - Modify the `RtpCodecCapability` struct in `consumer.rs` to include additional parameters for audio and video codecs - Add `RtpHeaderExtension` structs for various media kinds and URIs in `consumer.rs` - Refactor the `ExecutorGuard` struct in `consumer.rs` to use a new `new` method instead of the `impl` block - Modify the `create_executor` function in `consumer.rs` to use the new `ExecutorGuard` initialization - Modify the `init` function in `consumer.rs` to return multiple values rather than a single tuple - Remove the `#[allow(dead_code)]` attribute from the `impl RtpParameters` block in `rtp_parameters.rs`
I have removed ignoring dead_code warnings. I have used named fields as suggested. Please let me know if there is anything I need to change :) |
While going through the commit @nazar-pc made on their personal repo, I realized I missed something: Silencing clippy lints on files generated by plaun codegen: nazar-pc@7cdf648#diff-4bce653f545fe2edb899732221932e371b14c992e8304ab8f6a9677a142a7ec8R4 I did this same exact change and I can confirm that this is what caused #1413
I don't think I am smart enough to figure this one out. I deleted the registry folder as mentioned in #1413' s thread - but the same error kept happening. |
During development files are stored in the project's directory. Delete everything in |
Now this is ready to merge, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all comments/suggestions were ported into here still, Inaki
Box<dyn (FnMut(UvAsyncT) -> Option<Vec<u8>>) + Send + 'static>, | ||
); | ||
pub(super) struct ChannelReadCallback { | ||
_callback: Box<dyn (FnMut(UvAsyncT) -> Option<Vec<u8>>) + Send + 'static>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really like for comments to be present at such locations
I have made all required changes. Please let me know if I have missed any. If there are no more changes and the tests succeeds, we can merge this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for contribution and patience!
Merging, thanks a lot. |
I've updated Rust CHANGELOG for next release: a80630a |
hex_as_bytes
function to return an array of bytes based on input lengthoutput
parameter inhex_as_bytes
functionhex_as_bytes
function to use generic type and constant size