-
Notifications
You must be signed in to change notification settings - Fork 232
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
Async runtime for function binding defined in UDL file #2219
Comments
That's interesting! Re your question, I think that's not possible, although I believe it would not be particularly difficult to add. |
I've started implementing the If it comes to build time, it is not a big deal since UDL speeds up only clean build in my configuration. PS. What PS2. By so-called scaffolding I mean exporting pub fun, struct, enum as an c interface for foreign targets. As I understand: Semicompilation to C grants interoperability for FFI. PS3. But what about UDL manifests for Xcompilation? Can UDLs be nested across cargo workspace for libraries that cross compile? EDIT: |
Sorry for no response, I just got back from a break! I also misunderstood the problem when I said "not particularly difficult" :) This will require some fiddling in that macro code. I don't understand the motivation.
uniffi-bindgen doesn't have a "procmacro mode". It does have a UDL mode, which generate .rs code - but that generated code uses the procmacros. I can't see how a UDL project could be faster to build than one without a UDL. |
Forgive me for having little knowledge of crosscompilation. I'm guessing a lot without knowing, like a fool. ^^ In all the tutorials I've found, proc macros require me to compile the whole project to the default/native target before generating bindings for the foreign target. It is because of With UDL, I can build my static library for foreign targets first and then generate bindings from .udl files without recompiling the library for the native target. Is it possible to use a static library cross-compiled for the foreign target as a parameter for |
I see - although I guess I'm a little surprised you can't generate the bindings from the foreign target - maybe that's a better thing to lean in to? The UDL path will also bite you if you ever want to end up with multiple crates sharing uniffi types. |
UDL path feels coarse, especially for the beginner, because there is hardly any support from the UniFFI parser in debugging mistakes in UDL syntax. But I have a lot of determination to go through. My project is still in the proof-of-concept phase. The sooner it fails, the better decision I'll make for further development. |
It's more like "multi-crate interoperability typically requires generating the bindings from a built library instead of from a single UDL". It should be possible to change this so you can supply all the UDL files, but I don't think that's implemented. The issue isn't proc-macros vs UDL, because UDL is largely implemented by leaning on proc-macros. |
Back to the issue :) This is quite difficult due to only the .rs generation needing to know the runtime. It might be easier to have an option to allow all UDL async functions to specify the tokio runtime - that would be less intrusive (but still non-trivial - I think we'd want it specified in uniffi.toml, but the .rs code generation doesn't seem to read that) and might handle most use-cases. |
I have a similar issue. So, for now, does it mean this kind of function signature |
You can use async-std runtime with both UDL and proc macros but tokio runtime currently works only with proc macros. |
I'm migrating from macros to UDL to decrease build time.
Is there any way to specify async runtime for an asynchronous function that has its definition in UDL marked with
[Async]
the same way I can do it with proc macro#[uniffi::export(async_runtime = "tokio")]
?From
lib.rs
:Without async runtime specified I'm getting a runtime error:
The text was updated successfully, but these errors were encountered: