Skip to content

chore(ffi): use ruma's built-in uniffi support for power levels#6161

Draft
Johennes wants to merge 1 commit intomatrix-org:mainfrom
Johennes:johannes/uniffi
Draft

chore(ffi): use ruma's built-in uniffi support for power levels#6161
Johennes wants to merge 1 commit intomatrix-org:mainfrom
Johennes:johannes/uniffi

Conversation

@Johennes
Copy link
Contributor

@Johennes Johennes commented Feb 11, 2026

This is the smallest possible way that I could find to start using ruma/ruma#2338 in the FFI bindings. It doesn't really improve much on its own because the types that were replaced here are still used elsewhere. I thought it'd be good to start small though.

The only difference of the two types in the foreign language should be the use of Custom vs. Other.

  • Public API changes documented in changelogs (optional)

@Johennes Johennes force-pushed the johannes/uniffi branch 3 times, most recently from 0afd17b to e0e9256 Compare February 11, 2026 13:15
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.80%. Comparing base (70665a8) to head (5acec1d).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6161   +/-   ##
=======================================
  Coverage   89.79%   89.80%           
=======================================
  Files         365      365           
  Lines      100469   100469           
  Branches   100469   100469           
=======================================
+ Hits        90215    90224    +9     
+ Misses       6721     6714    -7     
+ Partials     3533     3531    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing Johennes:johannes/uniffi (5acec1d) with main (70665a8)

Open in CodSpeed

@Johennes
Copy link
Contributor Author

This is failing the complement-crypto tests now. These downgrade uniffi to 0.28.3. This no longer works because ruma's new uniffi support depends on changes from uniffi 0.31.0.

In particular:

  • doc(hidden) doesn't work in 0.28.3
  • uniffi::export only works on functions and impl blocks in 0.28.3 (ruma uses uniffi::export(Display, Eq, Hash) on an enum)
  • In 0.28.3 custom_type! only takes two type parameters and then you need to implement UniffiCustomTypeConverter. In 0.31.0 the macro takes the converters directly in a third argument

I can think of the following ways to resolve this:

  1. Split the uniffi implementation in ruma into two features, one that works with 0.28.3 and one that uses 0.31.0
  2. Change the rebuild_rust_sdk.sh script from complement to hack the changes into a local ruma checkout

I'm not sure which of these is worse but maybe I've missed a better option?

@jplatte
Copy link
Collaborator

jplatte commented Feb 12, 2026

The better option is to help move NordSecurity/uniffi-bindgen-go#86 forward, IMHO.

@Johennes
Copy link
Contributor Author

The better option is to help move NordSecurity/uniffi-bindgen-go#86 forward, IMHO.

That's still two minor versions behind what ruma needs but, yes, ideally the complement crypto tests wouldn't have to downgrade uniffi in the first place.

@jplatte
Copy link
Collaborator

jplatte commented Feb 13, 2026

Yeah, but it would unblock additional upgrades (which may be much easier than that one, if you're lucky ^^).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants