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

Support ThinArc for other dynamically sized types #10

Open
thomcc opened this issue Apr 13, 2020 · 5 comments
Open

Support ThinArc for other dynamically sized types #10

thomcc opened this issue Apr 13, 2020 · 5 comments

Comments

@thomcc
Copy link
Contributor

thomcc commented Apr 13, 2020

A ThinArcStr would be pretty easy to support (would just wrap a ThinArc<H, u8> -- you can already do this by using triomphe).

The use case I care more about would be a way of having a 1-pointer Arc (pretty useful for FFI stuff)... but I'm not sure how possible this is though, given that we don't have a way to get a trait object vtable pointer...

@NobodyXu
Copy link
Contributor

NobodyXu commented Dec 4, 2021

Even if we can obtain that, the layout of that vtable can still change though.

So maybe just generate an explicit vtable for the types you care?

@Manishearth
Copy link
Owner

It probably can be done with the new (unstable) pointer metadata APIs

@NobodyXu
Copy link
Contributor

NobodyXu commented Dec 4, 2021

But ASAIK it doesn't provide any API for retrieving the vtable and call one of these methods.

@Manishearth
Copy link
Owner

you can reconstruct the trait object as an &dyn on the rust side

@NobodyXu
Copy link
Contributor

NobodyXu commented Dec 4, 2021

Sorry I misunderstood the topic.
I was thinking about calling rust dyn trait from C/C++.

If you are talking about passing the pointer to C/C++ then get it back, I think to_raw_parts and from_raw_parts can be used to archive this, though this are available only on nightly channel.

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

3 participants