A little experiment with macros instead of build scripts. #386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit is basically me messing around with procedural macros,
to try them out as a potential future iteration of the UniFFI
developer experience.
As a crate author, I think it would be amazing not to have to
worry about .udl files and built scripts and what-not, but
instead be able to declare my API with a macro and have Rust
just take care of the details. This commit is a tiny experiment
in that direction, based on existing features of UniFFI.
The idea is that I can wrap my Rust code in a little macro
like this:
And I can provide a corresponding
my_component.udl
file thatdeclares the interface, and all the Rust scaffolding code just
gets taken care of automagically.
I still have to provide a
.udl
file, but I hope you can imagineone day the possibility of generating the interface definition
directly from the Rust code that is decorated by the macro.
Not any time soon! But one day...
Curious to hear any early impressions on these shenanigans :-)