Conversation
In order to handle multiple connection to radios and to be able to close the USB radio once all connections are dropped, the LinkContext was using Arc<SharedCrazyradio> and Weak<SharedCrazyradio>. This was not how the SharedCrazyradio was intended to be used, it was internded to be cloned to share the radio, not access by multiple unmutable references. This commit makes the SharedCrazyradio type encode this requirement by taking &mut self to most methods. It also adds a WeakSharedCrazyradio to handle the USB device management. The Crate version is bumped up since this is a breaking change.
There was a problem hiding this comment.
Pull request overview
This PR refactors the SharedCrazyradio API to enforce exclusive access semantics by changing most method signatures from &self to &mut self. This change addresses a design issue where the type was being used through multiple immutable references rather than being cloned as intended. The PR also introduces a WeakSharedCrazyradio type for managing weak references to the radio, enabling proper USB device lifecycle management.
Changes:
- Modified method signatures for
send_packet,send_packet_no_ack,scan_async,send_packet_async, andsend_packet_no_ack_asyncto take&mut selfinstead of&self - Added
WeakSharedCrazyradiostruct withupgrade()method for creatingSharedCrazyradioinstances from weak references - Added
downgrade()method toSharedCrazyradiofor creating weak references - Added
#![deny(missing_docs)]directive and documented previously undocumented public APIs - Updated examples to use mutable bindings for
SharedCrazyradioinstances - Bumped crate version from 0.3.1 to 0.4.0
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared_radio.rs | Changed method signatures to &mut self, added WeakSharedCrazyradio type and related methods |
| src/lib.rs | Added missing documentation for public APIs, exported WeakSharedCrazyradio, added #![deny(missing_docs)] directive |
| examples/async_scan.rs | Updated to use mutable binding for SharedCrazyradio |
| examples/async_broadcast.rs | Updated to use mutable binding for SharedCrazyradio |
| Cargo.toml | Bumped version from 0.3.1 to 0.4.0 for breaking API change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
evoggy
approved these changes
Feb 5, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to handle multiple connection to radios and to be able to close the USB radio once all connections are dropped, the LinkContext was using Arc and Weak.
This was not how the SharedCrazyradio was intended to be used, it was internded to be cloned to share the radio, not access by multiple unmutable references.
This PR makes the SharedCrazyradio type encode this requirement by taking
&mut selfto most methods. It also adds aWeakSharedCrazyradioobject to handle the USB device management.The Crate version is bumped up since this is a breaking change.