This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
Change the API to allow streaming & no callback to alloc #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
This is a proposal to support streaming (at least in the API and for responses), avoid the
alloc
function, and simplify the current implementation while making it closer to other WASI proposals.req()
now returns a handle to aResponse
object, along with the status code.A
Response
object can be then used to:A
body_read()
function pulls as many bytes as the client wants, and returns0
when the end of the stream is reached.This makes it compatible with streaming, doesn't require any dynamic memory allocation, and allows the client to control the maximum response size it's willing to accept.
For conveniency, the Rust and AssemblyScript bindings also have a
readAll
function that reads everything until the end and puts that into a dynamically allocated array.Usage in an app using wasmtime is now similar to wasi (core) and other WASI proposals, with an object and an
add_to_linker()
function.Errors are a little bit easier to keep track of, by using Rust errors, that are converted to return codes when needed. WITX is supposed to provide eventually provide the magic to get error strings from that.
Dependencies have been updated, especially
wasmtime
.