Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Use the new sliding sync version API from the Rust SDK #128

Merged
merged 5 commits into from
Sep 3, 2024

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Aug 27, 2024

Anticipating the merge of matrix-org/matrix-rust-sdk#3889. The configuration of sliding sync on the Client has changed. This patch updates this project to match this change.

Please wait for the PR on matrix-rust-sdk to be merged before merging this one.

internal/api/rust/rust.go Outdated Show resolved Hide resolved
@Hywan
Copy link
Member Author

Hywan commented Aug 28, 2024

It seems that we are hitting a bug in uniffi-go sadly… It fails to transform the SlidingSyncVersionBuilderProxy into a correct Rust value with the following error:

panic: invalid enum value `&{http://127.0.0.1:32779/}` in FfiConverterTypeSlidingSyncVersionBuilder.Write

which is an error generated by uniffi-go:

func (FfiConverterTypeSlidingSyncVersionBuilder) Write(writer io.Writer, value SlidingSyncVersionBuilder) {
	switch variant_value := value.(type) {
	case SlidingSyncVersionBuilderNone:
		writeInt32(writer, 1)
	case SlidingSyncVersionBuilderProxy:
		writeInt32(writer, 2)
		FfiConverterStringINSTANCE.Write(writer, variant_value.Url)
	case SlidingSyncVersionBuilderNative:
		writeInt32(writer, 3)
	case SlidingSyncVersionBuilderDiscoverProxy:
		writeInt32(writer, 4)
	case SlidingSyncVersionBuilderDiscoverNative:
		writeInt32(writer, 5)
	default:
		_ = variant_value
		panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterTypeSlidingSyncVersionBuilder.Write", value))
	}
}

In this patch, the value is:

	slidingSyncVersion := matrix_sdk_ffi.SlidingSyncVersionBuilderProxy{Url: opts.SlidingSyncURL}

which looks correct to me.

The following code is generated:

type FfiDestroyerTypeSlidingSyncVersion struct{}

func (_ FfiDestroyerTypeSlidingSyncVersion) Destroy(value SlidingSyncVersion) {
	value.Destroy()
}

type SlidingSyncVersionBuilder interface {
	Destroy()
}

type SlidingSyncVersionBuilderProxy struct {
	Url string
}

func (e SlidingSyncVersionBuilderProxy) Destroy() {
	FfiDestroyerString{}.Destroy(e.Url)
}

@kegsay kegsay self-requested a review September 3, 2024 08:19
@kegsay kegsay merged commit 7da7422 into matrix-org:main Sep 3, 2024
4 checks passed
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