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

Allow Rust workers to return an array of bytes too #44

Closed
Angelmmiguel opened this issue Nov 24, 2022 · 0 comments · Fixed by #45
Closed

Allow Rust workers to return an array of bytes too #44

Angelmmiguel opened this issue Nov 24, 2022 · 0 comments · Fixed by #45
Assignees
Labels
🚨 breaking change Introduces a breaking change in the project 🚀 enhancement New feature or request

Comments

@Angelmmiguel
Copy link
Contributor

Rust workers return a http::Response object that it's lately serialized into a UTF-8 JSON string. Then, the JSON is returned to the main wws service via WASI stdout. Note that the current seralized JSON includes the body and any other related metadata such as headers and status code.

This beahvior limits the capabilities of the workers as some tasks may return non UTF-8 entities. For example, we may want to generate a binary file that can be represented with a Vec<u8> in Rust, but not as a String. For this reason, we plan to add support for an array of bytes (Vec<u8>) in Rust workers too. This will introduce a breaking change as the Rust kit assumes the worker will return a String.

Supporting multiple values in Rust is simple, although we still need to make it serializable to JSON. To accomplish this, we plan to encode non-String values with base64. This is an initial iteration as base64 will introduce a performance penalty. In the future, we will stop using JSON in favor of other formats that supports all the use cases without base64.

@Angelmmiguel Angelmmiguel added 🚀 enhancement New feature or request 🚨 breaking change Introduces a breaking change in the project labels Nov 24, 2022
@Angelmmiguel Angelmmiguel self-assigned this Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 breaking change Introduces a breaking change in the project 🚀 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant