[WIP] gcoap: adapt to API change in PR 20900#129
[WIP] gcoap: adapt to API change in PR 20900#129maribu wants to merge 3 commits intoRIOT-OS:mainfrom
Conversation
In PR 20900 promotes access to header fields through helper functions on the C side, in the hope that this will allow similar but not quite UDP transports in addition to UDP (TCP and WebSocket) directly in nanocoap. This adapts and uses a helper to access the header instead.
|
@chrysn What would be the idomatic way to do this change backward-compatible? The |
|
I'll check, but the riot-wrappers shouldn't expose any of the fields anyway, so they can just switch over to the accessors in a compatible way. |
chrysn
left a comment
There was a problem hiding this comment.
Looks good already -- is RIOT doing a release transition to provide coap_pkt_set_code and only then break the struct access API, or is this an instant-breaking change in RIOT?
If there is transition, I think we can just do this as-is already, at latest when coap_pkt_set_code is available.
If there is a breaking change without transition release, there'll need to be a marker based on which to infer the right behavior. (I've simplified markers recently because most of it could be done through riotbuild.h in recent times; not sure that's the case here).
Co-authored-by: chrysn <[email protected]>
Sadly, the helper I could split out a PR to add the setter and backport that to the latest release, hoping on getting a release maintainer approval for a feature backport. But that would still bump the RIOT version requirements of the rust-riot-wrappers. |
|
With the plan laid out in RIOT-OS/RIOT#20900 (comment), it should be fair to have this PR's change conditional: if any of the new modules are in (say, We don't have a dependency on the cfg-if crate in the wrappers, so the old implementation would need to be kept in sync with a |
|
The proposed path did not work out: Neither c2rust nor bindgen support the unnamed-union trick. (In hindsight, that could have been clear: There are no unnamed unions in Rust). The next best thing is probably introducing a marker that decides based on the presence of the new accessor whether or not to do the new thing (as Rust's rust-lang/rust#64797 is not there yet). As that kind of markers is not around, I'm taking the liberty to add that. |
|
To be fair: The unnamed So this trick is exactly the kind of bad black magic that made a lot of people switch to rust. |
In PR 20900 promotes access to header fields through helper functions on the C side, in the hope that this will allow similar but not quite UDP transports in addition to UDP (TCP and WebSocket) directly in nanocoap. This adapts and uses a helper to access the header instead.
[edit/chrysn: made PR a link]