Skip to content

Commit

Permalink
Bump rust SDK to latest main
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Jan 3, 2024
1 parent 02c28f3 commit 15e6266
Show file tree
Hide file tree
Showing 5 changed files with 2,051 additions and 1,139 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Build Rust FFI bindings
run: |
mkdir rust-sdk
(wget -O - "https://github.com/matrix-org/matrix-rust-sdk/archive/kegan/poljar-recovery-complement-fork.tar.gz" | tar -xz --strip-components=1 -C rust-sdk)
(wget -O - "https://github.com/matrix-org/matrix-rust-sdk/archive/kegan/complement-crypto.tar.gz" | tar -xz --strip-components=1 -C rust-sdk)
(cd rust-sdk && cargo build -p matrix-sdk-ffi)
ls -alh rust-sdk/target/debug
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ In order to generate these bindings, follow these instructions:
main uses a versioned uniffi release e.g 0.25.2)
- Get the bindings generator:
```
git clone https://github.com/NordSecurity/uniffi-bindgen-go.git
git clone https://github.com/kegsay/uniffi-bindgen-go.git # TODO: fallback to https://github.com/NordSecurity/uniffi-bindgen-go.git once https://github.com/NordSecurity/uniffi-bindgen-go/pull/34 lands
cd uniffi-bindgen-go
git checkout v0.2.0+v0.25.0
git submodule init
git submodule update
cd ..
Expand All @@ -119,7 +118,6 @@ cargo install uniffi-bindgen-go --path ./uniffi-bindgen-go/bindgen
- Generate the Go bindings to `./rust`: `uniffi-bindgen-go -l ../matrix-rust-sdk/target/debug/libmatrix_sdk_ffi.a -o ./rust ../matrix-rust-sdk/bindings/matrix-sdk-ffi/src/api.udl`
- Patch up the generated code as it's not quite right:
* Add `// #cgo LDFLAGS: -lmatrix_sdk_ffi` immediately after `// #include <matrix_sdk_ffi.h>` at the top of `matrix_sdk_ffi.go`.
* Replace field names `Error` with `Error2` to fix `unknown field Error in struct literal`.
- Sanity check compile `LIBRARY_PATH="$LIBRARY_PATH:/path/to/matrix-rust-sdk/target/debug" go test -c ./tests`


Expand Down
10 changes: 5 additions & 5 deletions internal/api/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *RustClient) Close(t *testing.T) {
func (c *RustClient) MustGetEvent(t *testing.T, roomID, eventID string) Event {
t.Helper()
room := c.findRoom(t, roomID)
timelineItem, err := room.GetEventTimelineItemByEventId(eventID)
timelineItem, err := room.Timeline().GetEventTimelineItemByEventId(eventID)
if err != nil {
fatalf(t, "MustGetEvent(rust) %s (%s, %s): %s", c.userID, roomID, eventID, err)
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func (c *RustClient) MustBackupKeys(t *testing.T) (recoveryKey string) {

func (c *RustClient) MustLoadBackup(t *testing.T, recoveryKey string) {
t.Helper()
must.NotError(t, "FixRecoveryIssues", c.FFIClient.Encryption().FixRecoveryIssues(recoveryKey))
must.NotError(t, "Recover", c.FFIClient.Encryption().Recover(recoveryKey))
}

func (c *RustClient) WaitUntilEventInRoom(t *testing.T, roomID string, checker func(Event) bool) Waiter {
Expand Down Expand Up @@ -220,7 +220,7 @@ func (c *RustClient) TrySendMessage(t *testing.T, roomID, text string) (eventID
}
})
defer cancel()
r.Send(matrix_sdk_ffi.MessageEventContentFromHtml(text, text))
r.Timeline().Send(matrix_sdk_ffi.MessageEventContentFromHtml(text, text))
select {
case <-time.After(11 * time.Second):
err = fmt.Errorf("SendMessage(rust) %s: timed out after 11s", c.userID)
Expand All @@ -234,7 +234,7 @@ func (c *RustClient) MustBackpaginate(t *testing.T, roomID string, count int) {
t.Helper()
r := c.findRoom(t, roomID)
must.NotEqual(t, r, nil, "unknown room")
must.NotError(t, "failed to backpaginate", r.PaginateBackwards(matrix_sdk_ffi.PaginationOptionsSimpleRequest{
must.NotError(t, "failed to backpaginate", r.Timeline().PaginateBackwards(matrix_sdk_ffi.PaginationOptionsSimpleRequest{
EventLimit: uint16(count),
}))
}
Expand Down Expand Up @@ -314,7 +314,7 @@ func (c *RustClient) ensureListening(t *testing.T, roomID string) *matrix_sdk_ff

c.Logf(t, "[%s]AddTimelineListener[%s]", c.userID, roomID)
// we need a timeline listener before we can send messages
result := r.AddTimelineListener(&timelineListener{fn: func(diff []*matrix_sdk_ffi.TimelineDiff) {
result := r.Timeline().AddListener(&timelineListener{fn: func(diff []*matrix_sdk_ffi.TimelineDiff) {
timeline := c.rooms[roomID].timeline
var newEvents []*Event
c.Logf(t, "[%s]AddTimelineListener[%s] TimelineDiff len=%d", c.userID, roomID, len(diff))
Expand Down
Loading

0 comments on commit 15e6266

Please sign in to comment.