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

feat(0.3): rework stream error handling/remove wasi:io usage #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions wit-0.3.0-draft/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/// Requests and Responses, as well as their headers, trailers, and bodies.
interface types {
use wasi:clocks/[email protected].{duration};
use wasi:io/[email protected].{error};

/// This type corresponds to HTTP standard Methods.
variant method {
Expand Down Expand Up @@ -92,18 +91,6 @@ interface types {
field-size: option<u32>
}

/// Attempts to extract a http-related `error-code` from the stream `error`
/// provided.
///
/// Stream operations may fail with a stream `error` with more information
/// about the operation that failed. This `error` can be passed to this
/// function to see if there's http-related information about the error to
/// return.
///
/// Note that this function is fallible because not all stream errors are
/// http-related errors.
http-error-code: func(err: borrow<error>) -> option<error-code>;

/// This type enumerates the different kinds of errors that may occur when
/// setting or appending to a `fields` resource.
variant header-error {
Expand Down Expand Up @@ -254,16 +241,24 @@ interface types {
resource body {

/// Construct a new `body` with the specified stream and trailers.
constructor(
/// This function returns a future, which will resolve
/// to an error code if transmitting stream data or trailers fails.
/// The returned future resolves to success once body stream and trailers
/// are fully transmitted.
new: static func(
%stream: stream<u8>,
trailers: option<future<trailers>>
);
) -> tuple<body, future<result<_, error-code>>>;

/// Returns the contents of the body, as a stream of bytes.
///
/// This function may be called multiple times as long as any `stream`s
/// returned by previous calls have been dropped first.
%stream: func() -> result<stream<u8>>;
///
/// On success, this function returns a stream and a future, which will resolve
/// to an error code if receiving data from stream fails.
/// The returned future resolves to success if body is closed.
%stream: func() -> result<tuple<stream<u8>>, future<result<_, error-code>>>;

/// Takes ownership of `body`, and returns a `trailers`. This function will
/// trap if a `stream` child is still alive.
Expand Down
Loading