Skip to content

feat(ffi): expose Room.get_state_event(), Room.account_data(), and Room.set_account_data()#6430

Open
lucasfeijo wants to merge 5 commits intomatrix-org:mainfrom
lucasfeijo:feat/ffi-room-state-and-account-data
Open

feat(ffi): expose Room.get_state_event(), Room.account_data(), and Room.set_account_data()#6430
lucasfeijo wants to merge 5 commits intomatrix-org:mainfrom
lucasfeijo:feat/ffi-room-state-and-account-data

Conversation

@lucasfeijo
Copy link
Copy Markdown

@lucasfeijo lucasfeijo commented Apr 9, 2026

Expose room-scoped state event reading and account data read/write through the FFI bindings.

Motivation

Non-Rust clients (Swift/iOS, Kotlin/Android) currently have no way to read arbitrary room state events or room-scoped account data through FFI. The underlying SDK already has Room::get_state_event(), Room::account_data(), and Room::set_account_data_raw() — this PR surfaces them.

  • Room.account_data(event_type) / Room.set_account_data(event_type, content) follow the same pattern as the existing Client.account_data() / Client.set_account_data()
  • Room.get_state_event(event_type, state_key) complements the already-merged Room.send_state_event_raw() (feat(ffi): expose Room.send_state_event_raw() #6350) with the read side

Tested by integrating a build into our iOS application.

  • I've documented the public API Changes in the appropriate CHANGELOG.md files.
  • This PR was made with the help of AI.

Signed-off-by:

@lucasfeijo lucasfeijo requested a review from a team as a code owner April 9, 2026 17:31
@lucasfeijo lucasfeijo requested review from bnjbvr and removed request for a team April 9, 2026 17:31
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.83%. Comparing base (ba46159) to head (4e78fa7).
⚠️ Report is 33 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6430      +/-   ##
==========================================
+ Coverage   89.82%   89.83%   +0.01%     
==========================================
  Files         378      378              
  Lines      103931   103931              
  Branches   103931   103931              
==========================================
+ Hits        93351    93367      +16     
+ Misses       6995     6982      -13     
+ Partials     3585     3582       -3     

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

Move `matrix_sdk_base` import to alphabetical position and collapse
single-param `account_data` signature to one line per rustfmt.

Made-with: Cursor
@lucasfeijo lucasfeijo marked this pull request as draft April 9, 2026 17:47
@lucasfeijo lucasfeijo marked this pull request as ready for review April 9, 2026 17:51
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 9, 2026

Merging this PR will degrade performance by 49.63%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 49 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation Restore session [memory store] 112 ms 222.2 ms -49.63%

Comparing lucasfeijo:feat/ffi-room-state-and-account-data (4e78fa7) with main (3d29db5)

Open in CodSpeed

@lucasfeijo
Copy link
Copy Markdown
Author

This looks like a false positive, because the changes don't touch any code paths related to session restore or memory store, the PR only adds account_data(), set_account_data(), and get_state_event() as new methods on Room. No existing code is modified.

@bnjbvr
Copy link
Copy Markdown
Member

bnjbvr commented Apr 13, 2026

It's indeed a false positive, this benchmark unfortunately is bimodal.

Copy link
Copy Markdown
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, makes sense! Small suggestions below

Comment thread bindings/matrix-sdk-ffi/src/room/mod.rs Outdated
@lucasfeijo lucasfeijo marked this pull request as draft April 13, 2026 16:24
Made-with: Cursor
@lucasfeijo lucasfeijo marked this pull request as ready for review April 13, 2026 17:04
@lucasfeijo lucasfeijo requested a review from bnjbvr April 13, 2026 17:04
Comment on lines +44 to +46
- Expose `Room.account_data()`, `Room.set_account_data()`, and `Room.get_state_event()`
through FFI bindings, allowing non-Rust clients to read/write room-scoped account data
and read room state events.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you apply the renamings here too, add the point about custom events, and include the PR number as done on other lines below?

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