fix(ffi): Export Eq and Hash traits in enums used as HashMap keys#6259
fix(ffi): Export Eq and Hash traits in enums used as HashMap keys#6259Slko wants to merge 1 commit intomatrix-org:mainfrom
Conversation
matrix_sdk_ffi::ruma::TagName and matrix_sdk_ffi::event::TimelineEventType enums that are used as HashMap keys by matrix_sdk_ffi::ruma::Tag and matrix_sdk_ffi::room::power_levels::RoomPowerLevels respectively should probably export Eq and Hash traits, so that we can generate bindings for languages that implement uniffi's record/HashMap type using a hash table (e.g. std::unordered_map in C++) Signed-off-by: Stanislav Skobelkin <[email protected]>
bnjbvr
left a comment
There was a problem hiding this comment.
C++ bindings? 👀 Nice!
Let's see how Complement Crypto likes those new additions…
|
Oops, I wasn't familiar with that that test suite. I guess it doesn't like them. That makes everything much more complicated... |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6259 +/- ##
==========================================
- Coverage 89.90% 89.90% -0.01%
==========================================
Files 372 372
Lines 102475 102475
Branches 102475 102475
==========================================
- Hits 92135 92126 -9
- Misses 6785 6790 +5
- Partials 3555 3559 +4 ☔ View full report in Codecov by Sentry. |
|
We're unfortunately stuck on older features of uniffi because Complement Crypto doesn't use the latest version. It's been updated recently, but it still might be a bit behind, or require some custom updates for the Go bindings generator 🤔 |
|
Yeah, seems like enum traits require at least UniFFI 0.30 which contains non-trivial number of breaking changes and new features, and most generators (including uniffi-bindgen-go) are stuck on 0.29.x. This could probably be worked around with a feature flag, but I feel like it's not worth it for such a minor change. |
Well there is hope: NordSecurity/uniffi-bindgen-go#88. |
matrix_sdk_ffi::ruma::TagNameandmatrix_sdk_ffi::event::TimelineEventTypeenums that are used asHashMapkeys bymatrix_sdk_ffi::ruma::Tagandmatrix_sdk_ffi::room::power_levels::RoomPowerLevelsrespectively should probably exportEqandHashtraits in the FFI as well, so that we can generate correct bindings for languages that implement UniFFI'srecord(in UDL)/HashMap(in proc-macros) type using a hash table (e.g.std::unordered_mapin C++).After applying these changes, I was able to generate working bindings using my WIP generator for C++ (that I haven't open-sourced yet).
Additional context: mozilla/uniffi-rs#2839
CHANGELOG.mdfiles.