Skip to content

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

@Angelmmiguel

Description

@Angelmmiguel

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions