feat: add wasi-0.3.0 draft#164
Conversation
Followed the example of `wasi-http` and `wasi-clocks` duplicating the
package in a subdirectory
- Remove `would-block` error code
- Replace `wasi:io/error.error` usage by `error-context`
- Replace `wasi:io/streams.input-stream` return values by `stream<u8>`
in return position
- Replace `wasi:io/streams.output-stream` return values by `stream<u8>`
in parameter position
- Guests should be able to rely on `stream.new` to construct
streams
- Merge `read{,via-stream}` into a singular `read`. Both functions take
an offset as a parameter and since they now return `stream<u8>`,
callers can limit the amount of bytes read by using the `stream<u8>`
directly, therefore functionality of both is identical
- Merge `write{,via-stream}` into a singular `write`. Both functions take
an offset and `stream<u8>` as a parameter.
It is assumed that `error-context` returned by writes to the stream and
reads from the stream are sufficient for error handling.
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
|
Same as in WebAssembly/wasi-sockets#111 (comment), removed the |
This seems to be better aligned with latest specification on error context https://github.com/WebAssembly/component-model/blob/cbdd15d9033446558571824af52a78022aaa3f58/design/mvp/Explainer.md#error-context-type > A consequence of this, however, is that components *must not* depend on the > contents of `error-context` values for behavioral correctness. In particular, > case analysis of the contents of an `error-context` should not determine > *error recovery*; explicit `result` or `variant` types must be used in the > function return type instead (e.g., > `(func (result (tuple (stream u8) (future $my-error)))`). Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
f1cc147 to
a7b76d0
Compare
WebAssembly/wasi-filesystem#164 (comment) Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
WebAssembly#164 (comment) Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
e60c2bf to
0a23094
Compare
WebAssembly#164 (comment) Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
0a23094 to
81bd8bb
Compare
WebAssembly/wasi-filesystem#164 (comment) Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
|
Thanks for putting this together! Overall this looks good. One additional thing we should look into is translating Similar to this discussion in wasi-sockets, what would you think about renaming
Could we simplify this interface by eliminating the outer |
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
07e2d44 to
eed891a
Compare
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
eed891a to
70fa400
Compare
This ensures that e.g.: ``` wit-bindgen markdown wit-0.3.0-draft -w imports --html-in-md ``` works with wit-bindgen 0.37 refs: WebAssembly/wasi-sockets@3abda6e refs: WebAssembly/wasi-sockets#111 (comment) Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
|
@sunfishcode could you please take another look at this PR? |
|
This looks good. There may be some more details to figure out, but we can iterate from here. |
* feat: add `wasi-0.3.0` draft
Followed the example of `wasi-http` and `wasi-clocks` duplicating the
package in a subdirectory
- Remove `would-block` error code
- Replace `wasi:io/error.error` usage by `error-context`
- Replace `wasi:io/streams.input-stream` return values by `stream<u8>`
in return position
- Replace `wasi:io/streams.output-stream` return values by `stream<u8>`
in parameter position
- Guests should be able to rely on `stream.new` to construct
streams
- Merge `read{,via-stream}` into a singular `read`. Both functions take
an offset as a parameter and since they now return `stream<u8>`,
callers can limit the amount of bytes read by using the `stream<u8>`
directly, therefore functionality of both is identical
- Merge `write{,via-stream}` into a singular `write`. Both functions take
an offset and `stream<u8>` as a parameter.
It is assumed that `error-context` returned by writes to the stream and
reads from the stream are sufficient for error handling.
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor: avoid introspecting `error-context`
This seems to be better aligned with latest specification on error context
https://github.com/WebAssembly/component-model/blob/cbdd15d9033446558571824af52a78022aaa3f58/design/mvp/Explainer.md#error-context-type
> A consequence of this, however, is that components *must not* depend on the
> contents of `error-context` values for behavioral correctness. In particular,
> case analysis of the contents of an `error-context` should not determine
> *error recovery*; explicit `result` or `variant` types must be used in the
> function return type instead (e.g.,
> `(func (result (tuple (stream u8) (future $my-error)))`).
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* chore: bump `@since` to `0.3.0`
WebAssembly/wasi-filesystem#164 (comment)
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor(0.3): simplify error handling
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor(0.3): asyncify `read-directory`
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* feat: update wit-deps to 0.5.0
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* drop `-draft` version suffix
This ensures that e.g.:
```
wit-bindgen markdown wit-0.3.0-draft -w imports --html-in-md
```
works with wit-bindgen 0.37
refs:
WebAssembly/wasi-sockets@3abda6e
refs:
WebAssembly/wasi-sockets#111 (comment)
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
WebAssembly/wasi-filesystem#164 (comment) Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Refs Ship WASIp3 (view)
Refs WebAssembly/wasi-sockets#111
Refs #156 (change sets seem to be complimentary)
Followed the example of
wasi-httpandwasi-clocksduplicating the package in a subdirectoryThis vendors
wasi-clocksfrom WebAssembly/wasi-clocks#77would-blockerror codewasi:io/error.errorusage byerror-contextwasi:io/streams.input-streamreturn values bystream<u8>in return positionwasi:io/streams.output-streamreturn values bystream<u8>in parameter position - Guests should be able to rely onstream.newto construct streamsread{,via-stream}into a singularread. Both functions take an offset as a parameter and since they now returnstream<u8>, callers can limit the amount of bytes read by using thestream<u8>directly, therefore functionality of both is identicalwrite{,via-stream}into a singularwrite. Both functions take an offset andstream<u8>as a parameter.It is assumed that
error-contextreturned by writes to the stream and reads from the stream are sufficient for error handling.See also