NordSecurity / uniffi-bindgen-go

Uniffi bindings generator for Golang
Mozilla Public License 2.0
75 stars 21 forks source link

Fix multiple async packages not working together #46

Closed arg0d closed 6 months ago

arg0d commented 6 months ago

Future continuation callback is a single global callback on Rust side. Its used to signal bindings from Rust when a future is ready. The problem is if multiple async packages set this callback, only one of these callbacks will be used by Rust code for futures from both packages.

The current implementation of this callback simply sends the continuation future result into a channel, but the channel type was using C.int8_t, which turns out to be a different type for each package, and channel raises an error when wrong type is being sent in the channel.

Luckily this callback is very simple, and it doesn't matter which package's callback is trigerred. So the fix is to use a channel type that is the same for both packages, regular int8 instead of C.int8_t.

Fixes #45

arg0d commented 6 months ago

@kegsay this should unblock you from creating a test for https://github.com/NordSecurity/uniffi-bindgen-go/pull/44, right?

kegsay commented 6 months ago

I believe so, I'll merge your branch in and give it a go, thanks!