-
Notifications
You must be signed in to change notification settings - Fork 104
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
derive that forwards From/ToBytes to specific encoding #661
Comments
Good idea! This would definitely reduce the amount of boilerplate when only one encoding is ever used for a type. |
I'd be up to look into implementing this, what would be your preferred API: // require serde::{Serialize, DeserializeOwned}
#[derive(FromJson, ToJson)]
#[derive(FromMsgpack, ToMsgpack)]
// prost::Message
#[derive(FromProst, ToProst)]
// require bytemuck::Pod
#[derive(FromRaw, ToRaw)] or #[derive(FromBytes, ToBytes}
// require serde::{Serialize, DeserializeOwned}
#[encoding(Json)]
#[encoding(Msgpack)]
// prost::Message
#[encoding(Prost)]
// require bytemuck::Pod
#[encoding(Raw)] |
I would prefer the latter because I think it would enable us to create something quite flexible. we could accept any generic tuple struct that implements ToBytes as argument to the encode attribute. |
I agree, I think the second option is preferred, we would just need to make sure that only one Thanks for picking this up - let me know if you run into any issues! |
closes #661. - [x] docs - [x] tests - [x] depend on `extism-convert/extism-pdk-path` feature in https://github.com/extism/rust-pdk extism/rust-pdk#47
My idea was to add to
extism_convert
either derive macros for the different data formats, or a singleEncoding
derive macro, that specifies a specific one.In:
Out:
This allows using it directly as function arguments/return type, and it automatically has the correct encoding (e.g., when sharing code between host and plugin)
The text was updated successfully, but these errors were encountered: