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

Adopt rustls-ffi arc_castable!, box_castable!, ref_castable! macros #11

Closed
cpu opened this issue Apr 23, 2024 · 1 comment
Closed

Adopt rustls-ffi arc_castable!, box_castable!, ref_castable! macros #11

cpu opened this issue Apr 23, 2024 · 1 comment

Comments

@cpu
Copy link
Member

cpu commented Apr 23, 2024

See rustls/rustls-ffi#404

It would help with the eventual move towards shared FFI helpers if this repo also adopted the Castable helper macros recently added in rustls-ffi.

Filing this as an issue instead of a PR making the switch to avoid unnecessary conflicts with in-progress work. We can do this at some future point.

@cpu
Copy link
Member Author

cpu commented Jun 27, 2024

I randomly thought about this and started looking at it. Based on how this codebase evolved I think the macros are of less use here.

Unlike in rustls-ffi we're not creating new opaque structs for each Castable at the site of implementing that trait and instead we're following a pattern of defining an unexported rust type in a sub module and then exporting a SCREAMING_SNAKE_CASE type alias in entry.rs. That means less boilerplate to motivate the macro.

Similarly, unlike in rustls-ffi we sometimes want the type alias to be for one rust type, but the Castable::RustType to be that type wrapped in NotThreadSafe. Handling that in the macros complicates them, and I think obscures the key detail of the castable being NotThreadSafe or not.

Overall: a nice idea but one I think we should pass on for now.

@cpu cpu closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
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

1 participant