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

External callback interfaces/traits feature request #2007

Open
Voronar opened this issue Mar 5, 2024 · 5 comments
Open

External callback interfaces/traits feature request #2007

Voronar opened this issue Mar 5, 2024 · 5 comments

Comments

@Voronar
Copy link

Voronar commented Mar 5, 2024

External callback interfaces not supported at the moment.
Please add the support or make foreign traits usable externally.

@badboy
Copy link
Member

badboy commented Mar 5, 2024

It would be nice if you could just a tiny bit expand on what your request is.
Or at the very least link to a time-stable link: https://github.com/mozilla/uniffi-rs/blob/0a5e2eb5760b4ce5549021ec91de546716de8db1/uniffi_meta/src/group.rs

@mhammond
Copy link
Member

mhammond commented Mar 5, 2024

Callback interfaces are less likely to get love moving forward. I was going to suggest you use an external "trait" instead, but noticed that too appears to not be supported :( I'll rename this to handle both cases because the work for both will be very similar.

@mhammond mhammond changed the title External callback interfaces feature request External callback interfaces/traits feature request Mar 5, 2024
@cowlicks
Copy link
Contributor

@mhammond can you say a little more about this? I'd have a few functions that accept simple callbacks in my api. I'm trying to figure out the best option for supporting these. The functions are mostly for convenience.

I'm wondering why was the callback interface deprecated? They are mentioned as "(soft) deprecated" in the docs (but not in the pro macro docs). Soft deprecated implies that I may be able to use and maybe wait for whatever future thing might be in the works to replace them. Are there plans to support callbacks in the future?

Why were external traits deprecated? I don't see this mentioned in the docs.

Sorry for all the questions. But I'm hoping with more info I may be able to help with a future solution.

@mhammond
Copy link
Member

callbacks are kinda soft-deprecated because "foreign traits" offer all the same capabilities with a more consistent interface. In particular, callback interfaces are passed to rust as a Box<dyn Trait> which makes sharing them complicated, whereas traits are passed around as Arc<dyn Trait>. I'm not aware of anything callbacks can do that traits can not, but this difference means traits are capable of things callbacks are not.

external traits were never deprecated - they just were never supported - just like they were not for callbacks. Of those 2, I suspect external traits will get support first as it covers more use-cases (ie, both traits that are not designed to be implemented externally and those that are).

@cowlicks
Copy link
Contributor

@mhammond Thank you! I understand now. I was confusing "foreign" and "external" traits above, when I read your comment that external traits are not supported.

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

4 participants