matrix-org / matrix-org/matrix-rust-sdk
Re-export ruma types under `matrix_sdk_common::types`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
This was borne from a conversation with @gnunicorn, @jplatte and @johannescpk in the Ruma Development room, where there was talk of woes related to switching between "ruma types" and "SDK types", particularly on the library user end, which then had to depend and import ruma separately from the SDK.
I think this can be solved by adding a new module under matrix_sdk_common (the most common denominator crate), types, which can then re-export common types (OwnedEventId, etc.) with its own documentation blurb and module reference.
After testing this, adding this module under matrix_sdk_base yields the following;
/// A self-owned event ID string.
///
/// For its borrowed variant, see [`UserId`]
pub use ruma::OwnedUserId;
/// A dynamically-sized event ID type, equivalent to plain [`str`].
///
/// Use inside borrows, [`Box`]es or [`Arc`](std::sync::Arc)s.
pub use ruma::UserId;
And, when swapping ruma::OwnedUserId with crate::types::OwnedUserId, it will link to matrix_sdk_base::types::OwnedUserId instead of ruma::OwnedUserId, allowing us to add supplementing documentation for the type, an introduction, extra invariants, further references, and more.
With this, we can give a good enough illusion that these types belong to the matrix rust sdk, while keeping their typing "identity" the same, allowing reuse among other projects that use ruma types.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the matrix_sdk_common crate and its proposed types module, then compare the example re-exports in matrix_sdk_base with the existing Ruma type usage. Done means common Ruma types such as OwnedEventId are re-exported under matrix_sdk_common::types with suitable documentation while retaining their type identity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100