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

Add support for multiple arguments #670

Open
ModProg opened this issue Jan 29, 2024 · 0 comments
Open

Add support for multiple arguments #670

ModProg opened this issue Jan 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ModProg
Copy link
Contributor

ModProg commented Jan 29, 2024

Currently, in extism calling plugin functions can only take a single argument.

I'd like macros like typed_plugin and plugin_fn to support multiple arguments, they would just convert them to use tuples under the hood.

IMO this could be implemented through ToBytes and FromBytes for Tuples where the individual fields implement those types.

This implementation could work as follows:

  1. () already does
  2. (T,) can just delegate to T
  3. (T1, T2, ...) add one extra usize (could possibly be a different integer type) per item. The memory layout of the bytes array produced by tuples would need to be <T1::to_bytes().len()> <T1::to_bytes()> <T2::to_bytes().len()> <T2::to_bytes()> ....

I'd imagine this would work quite well for rust, but I'm uncertain for other languages, e.g., such without an actual tuple type.

@nilslice nilslice added the enhancement New feature or request label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants