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

Compile error when using async traits #2

Open
SeanCheatham opened this issue Jan 3, 2025 · 1 comment
Open

Compile error when using async traits #2

SeanCheatham opened this issue Jan 3, 2025 · 1 comment
Assignees

Comments

@SeanCheatham
Copy link

Thanks a bunch for continuing the work on the uniffi KMP bindings. I've had some pretty solid success using your updates in a project that needed Kotlin 2 support.

While most things seem to work well so far, I noticed there are some issues when using async/future calls. In my particular use-case, I am attempting to define a foreign async trait like:

#[uniffi::export(with_foreign)]
#[async_trait::async_trait]
pub trait DataWriter: Send + Sync {
    async fn write(&self, data: Vec<u8>);
}

#[uniffi::export]
pub async fn foo(writer: &dyn DataWriter) -> () {
    writer.write(vec![1, 2, 3]).await;
}

After running through the bindgen, the resulting Kotlin code does not successfully compile. I took a quick look at the corresponding Async templates and it looks like it may only be partially implemented.

I'm curious if you've had a chance to use the async functionality in any of your projects, or if you might already have plans to update the async bindgen implementations? I tried to play around with it on my own but I'm not very familiar with the internals.

Thanks again!

@lebedenko-ubique lebedenko-ubique self-assigned this Jan 15, 2025
@lebedenko-ubique
Copy link
Collaborator

Hello there, sorry for the late reply and thanks for the kind words! We are aware of this issue, but it is currently not on top of our priority list. But if I have time I will have a look at it.

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

No branches or pull requests

2 participants