-
Notifications
You must be signed in to change notification settings - Fork 240
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
Foreign-implemented async traits #2017
Comments
bendk
added a commit
to bendk/uniffi-rs
that referenced
this issue
Mar 8, 2024
These methods input a completion function that they call when the async function is complete. They return a ForeignFuture struct, which represents the foreign task object and is used to drop/cancel futures. Like Rust, dropping and cancelling are coupled together into one operation. - Added `RustCallStatus` as an `FfiType` variant, since I wanted to use it in the `ForeignFutureResult` structs. In theory, we could define `RustCallStatus` a `FfiType::Struct`, but I didn't want to introduce that change in this PR. - Fixed the result mapping code to work with async functions. Before we were executing the mapping call, then awaiting the result, but we need to do that in the opposite order (`foo.into().await` vs `foo.await.into()`). Also, specify the return type generics for `rust_future_new` so that the Rust can figure out the into() generics.
bendk
added a commit
to bendk/uniffi-rs
that referenced
this issue
Mar 8, 2024
These methods input a completion function that they call when the async function is complete. They return a ForeignFuture struct, which represents the foreign task object and is used to drop/cancel futures. Like Rust, dropping and cancelling are coupled together into one operation. - Added `RustCallStatus` as an `FfiType` variant, since I wanted to use it in the `ForeignFutureResult` structs. In theory, we could define `RustCallStatus` a `FfiType::Struct`, but I didn't want to introduce that change in this PR. - Fixed the result mapping code to work with async functions. Before we were executing the mapping call, then awaiting the result, but we need to do that in the opposite order (`foo.into().await` vs `foo.await.into()`). Also, specify the return type generics for `rust_future_new` so that the Rust can figure out the into() generics.
bendk
added a commit
to bendk/uniffi-rs
that referenced
this issue
Mar 8, 2024
These methods input a completion function that they call when the async function is complete. They return a ForeignFuture struct, which represents the foreign task object and is used to drop/cancel futures. Like Rust, dropping and cancelling are coupled together into one operation. - Added `RustCallStatus` as an `FfiType` variant, since I wanted to use it in the `ForeignFutureResult` structs. In theory, we could define `RustCallStatus` a `FfiType::Struct`, but I didn't want to introduce that change in this PR. - Fixed the result mapping code to work with async functions. Before we were executing the mapping call, then awaiting the result, but we need to do that in the opposite order (`foo.into().await` vs `foo.await.into()`). Also, specify the return type generics for `rust_future_new` so that the Rust can figure out the into() generics.
bendk
added a commit
to bendk/uniffi-rs
that referenced
this issue
Mar 8, 2024
These methods input a completion function that they call when the async function is complete. They return a ForeignFuture struct, which represents the foreign task object and is used to drop/cancel futures. Like Rust, dropping and cancelling are coupled together into one operation. - Added `RustCallStatus` as an `FfiType` variant, since I wanted to use it in the `ForeignFutureResult` structs. In theory, we could define `RustCallStatus` a `FfiType::Struct`, but I didn't want to introduce that change in this PR. - Fixed the result mapping code to work with async functions. Before we were executing the mapping call, then awaiting the result, but we need to do that in the opposite order (`foo.into().await` vs `foo.await.into()`). Also, specify the return type generics for `rust_future_new` so that the Rust can figure out the into() generics.
bendk
added a commit
to bendk/uniffi-rs
that referenced
this issue
Mar 8, 2024
These methods input a completion function that they call when the async function is complete. They return a ForeignFuture struct, which represents the foreign task object and is used to drop/cancel futures. Like Rust, dropping and cancelling are coupled together into one operation. - Added `RustCallStatus` as an `FfiType` variant, since I wanted to use it in the `ForeignFutureResult` structs. In theory, we could define `RustCallStatus` a `FfiType::Struct`, but I didn't want to introduce that change in this PR. - Fixed the result mapping code to work with async functions. Before we were executing the mapping call, then awaiting the result, but we need to do that in the opposite order (`foo.into().await` vs `foo.await.into()`). Also, specify the return type generics for `rust_future_new` so that the Rust can figure out the into() generics.
bendk
added a commit
to bendk/uniffi-rs
that referenced
this issue
Mar 14, 2024
These methods input a completion function that they call when the async function is complete. They return a ForeignFuture struct, which represents the foreign task object and is used to drop/cancel futures. Like Rust, dropping and cancelling are coupled together into one operation. - Added `RustCallStatus` as an `FfiType` variant, since I wanted to use it in the `ForeignFutureResult` structs. In theory, we could define `RustCallStatus` a `FfiType::Struct`, but I didn't want to introduce that change in this PR. - Fixed the result mapping code to work with async functions. Before we were executing the mapping call, then awaiting the result, but we need to do that in the opposite order (`foo.into().await` vs `foo.await.into()`). Also, specify the return type generics for `rust_future_new` so that the Rust can figure out the into() generics.
bendk
added a commit
to bendk/uniffi-rs
that referenced
this issue
Mar 18, 2024
These methods input a completion function that they call when the async function is complete. They return a ForeignFuture struct, which represents the foreign task object and is used to drop/cancel futures. Like Rust, dropping and cancelling are coupled together into one operation. - Added `RustCallStatus` as an `FfiType` variant, since I wanted to use it in the `ForeignFutureResult` structs. In theory, we could define `RustCallStatus` a `FfiType::Struct`, but I didn't want to introduce that change in this PR. - Fixed the result mapping code to work with async functions. Before we were executing the mapping call, then awaiting the result, but we need to do that in the opposite order (`foo.into().await` vs `foo.await.into()`). Also, specify the return type generics for `rust_future_new` so that the Rust can figure out the into() generics.
bendk
added a commit
that referenced
this issue
Mar 18, 2024
Foreign-implemented async trait methods (#2017)
This one was implemented in #2018 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We currently allow Rust code to implement async trait methods, but foreign implementations are not supported. We should extend support to allow for foreign code.
I think this is a key feature for full async support. It allows Rust code to define an async method that depends on a foreign async method. This allows users to use async code without running a Rust async runtime, you can effectively piggyback on the foreign async runtime.
The text was updated successfully, but these errors were encountered: