[RSDK-13658] Plumb force_relay/force_p2p/turn_uri through C FFI#176
[RSDK-13658] Plumb force_relay/force_p2p/turn_uri through C FFI#176danielbotros wants to merge 3 commits intomainfrom
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) throughviam_dialso non-Rust SDKs (Python) can drive ICE relay/P2P testing and TURN-server filtering.rt_ptrsort_ptrkeeps its original positional slot — required for the C++ source-compat scheme below.dialcontinues to provide the original 7-arg ABI by trampolining intoviam_dialwith the new args defaulted (rt_ptr, false, false, NULL).C++ SDK source compatibility
The C++ SDK calls
viam_dial(uri, entity, type, payload, allow_insec, timeout, rt_ptr)(7 args). To avoid breaking that call site,cbindgen.tomlnow emits a C++-onlyextern "C"re-declaration in the generated header trailer that adds defaults to the three new trailing params:C++ allows a later declaration of an
extern "C"function to add default arguments; the compiler merges them. So:Downstream PRs (do not merge until rust-utils releases)
viam_dialstub used on stubbed platforms (currently non-x86_64 Windows) to match the 10-arg signature.viam_dialsymbols and exposes the new dial options.Test plan
cargo build --releasecleancargo test --lib --releasepasses_viam_dialand (deprecated)_dialviam_init_rust_runtime/viam_free_rust_runtimeround-tripdial.cpp:209-210against the cbindgen-generated header + the new static lib — resolves via the C++ default-arg trailer, no warnings.🤖 Generated with Claude Code