-
Notifications
You must be signed in to change notification settings - Fork 100
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
feat(convert): add derive macros for To and FromBytes #667
Conversation
a3bc0de
to
ea84971
Compare
cc4e9db
to
b45b57a
Compare
b45b57a
to
9b4ecb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - I have a commit where I changed some of the tests to use this and it makes the developer experience very nice! Those changes are here: https://github.com/extism/extism/tree/test-convert-derive-macros
I'm not 100% clear how the right way to do the path resolution in this case, but I think your solution works pretty well - as long as the end user doesn't need to add any additional features when using the extism
or extism-pdk
crates.
I think we just need some more tests and documentation (like you mentioned in your issue) and it should be ready!
Yeah, that is the idea. This would need to be extended for any “entry point” crates that are created in the future. But sadly, rust still doesn't have a |
Hey @ModProg - how's this going? If you're stuck on the documentation/testing I can help pick some of that up next week. |
be37884
to
fa43dc0
Compare
// Makes proc-macros able to resolve `::extism_convert` correctly | ||
extern crate self as extism_convert; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will only be relevant as soon as proc macros are used inside this crate. So not yet. But this will avoid any future confusion.
#[doc(inline)] | ||
pub use extism_convert as convert; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the convert
crate show up as a module instead of a reexport. This makes the paths inside the examples correct.
I added some, but feel free to expand on them. |
# Only required for tests run from the workspace root, as that enables the `extism-path` feature. | ||
extism.workspace = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could add a hidden # mod extism {pub use extism_convert as convert;}
to the doc tests.
The last two commits feel a bit like hacks to make ci happy :D |
Ah yeah the path resolution features seem to add some additional complexity around docs/testing but it seems worth it. I think these changes looks great and appreciate the effort updating the docs! I will merge this later after I experiment with the changes a little more. |
closes #661.
extism-convert/extism-pdk-path
feature in https://github.com/extism/rust-pdk feat: add convert derive macros rust-pdk#47