-
Notifications
You must be signed in to change notification settings - Fork 862
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
[embassy-net]: Mutability mismatch between embassy_net_driver::RxToken::consume()
and smoltcp::phy::RxToken::consume()
#3670
Comments
can you expand on this? it seems to me you can make the callback require EDIT: okay should've read the PR in the pingback. I've commented there. |
Thankfully, there is a trivial solution provided for this issue. I'll explain it here for future reference; Basically, in esp-wifi, we implement the traits for both Example: impl<Dm: WifiDeviceMode> embassy_net_driver::RxToken for WifiRxToken<Dm> {
fn consume<R, F>(self, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
{
self.consume_token(f)
}
}
#[cfg(feature = "smoltcp")]
impl<Dm: Sealed> smoltcp::phy::RxToken for WifiRxToken<Dm> {
fn consume<R, F>(self, f: F) -> R
where
F: FnOnce(&[u8]) -> R,
{
self.consume_token(|t| f(t))
}
}
impl<Dm: Sealed> WifiRxToken<Dm> {
/// Consumes the RX token and applies the callback function to the received
/// data buffer.
pub fn consume_token<R, F>(self, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
{
// ...
}
} That being said, there is still a mismatch between the two APIs and the question is, does the trait provided by If so, I'll leave this issue open for addressing it. |
Being consistent would be nice, but it would be a breaking change for ( |
The same breaking change argument could've been made for smoltcp (see I'll close this issue as the discussion provided an easy and trivial fix for this specific edge case. |
smoltcp doesn't split the traits into a separate crate, so it'd have been breaking anyway even if the trait didn't change. |
smoltcp::phy::RxToken::consume() was updated in:
RxToken
'sconsume
argument. smoltcp-rs/smoltcp#924To change the mutability of the callback. The equivalent in
embassy-net-driver
hasn't been updated, creating a mismatch between the two traits. If an implementer wants to use the same callback for implementingembassy-net-driver
andsmoltcp
, they cannot because the mutability doesn't match anymore.The text was updated successfully, but these errors were encountered: