[RSDK-13658] Plumb force_relay/force_p2p/turn_uri through C FFI#176
Conversation
Exposes the DialBuilder methods added in #170 (force_relay, force_p2p, turn_uri) through viam_dial so non-Rust SDKs can drive ICE relay/P2P testing and TURN-server filtering. The deprecated `dial` keeps its 7-arg ABI by trampolining into viam_dial with `false, false, NULL` defaults. BREAKING (C ABI): viam_dial now takes 10 args instead of 7. Any non-Rust consumer linking against viam_dial must rebuild against the new header. Consumers still using the deprecated `dial` are unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
55422d7 to
9c6b582
Compare
stuqdog
left a comment
There was a problem hiding this comment.
The logic changes all look reasonable but I'm pretty sure this will break existing C++ SDK instances. When C++ builds it looks for an existing rust-utils instance and if it doesn't find one it just downloads the latest release.
One possible fix would be to update the cbindgen process to generate a function overload signature for viam_dial that uses the old signature and puts default values in. Happy to chat more in person if you have questions or thoughts!
I went ahead and changed the cbindgen config to emit a C++ only header that fills in default values for the last 3 new dial options args so the C++ SDK can compile against the 10-arg header. This requires a small follow up PR to the C++ SDK to update the |
Summary
DialBuilderoptions landed in [RSDK-13658] Add force relay and force p2p dial flags #170 (force_relay,force_p2p,turn_uri) through the C FFI as an opaque, ABI-stable options handle; new fields in the future require only a new setter, never a header change.viam_dial(7-arg) is left untouched. Non-Rust consumers (C++ SDK) see no breaking change. It is now#[deprecated]in favor ofviam_dial_with_opts.viam_dial, the deprecateddial, and the newviam_dial_with_optsonto a shared privatedial_implso they can't drift.DialOptsstruct never appears in the generated header; cbindgen sees onlyvoid *. Future field additions don't break the C ABI.Test plan
cargo build --release+cargo clippy --all-featurescleancargo test --release --libpasses (4/4)nmconfirms exports:_viam_dial_opts_new/_free/_set_*,_viam_dial_with_opts,_viam_dial(deprecated),_dial(deprecated)cbindgenregenerates a clean header. Every opts param isvoid *, theDialOptsRust struct never appearsviam_dial, opts lifecycle, all setters (NULL/empty/value paths), andviam_dial_with_opts.-Wall -Wextraclean, links against the dylibforce_relaypins to relay candidates andforce_p2pstrips them — pending with the paired python-sdk PR