Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
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
24 changes: 19 additions & 5 deletions wit-0.3.0-draft/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,27 @@ interface types {
/// trailers at any given time.
resource body {

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

/// Construct a new `body` with the specified stream and trailers.
///
/// 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(
new-with-trailers: static func(
%stream: stream<u8>,
trailers: option<future<trailers>>
trailers: future<trailers>
) -> tuple<body, future<result<_, error-code>>>;

/// Returns the contents of the body, as a stream of bytes.
Expand All @@ -260,9 +273,10 @@ interface types {
/// 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.
finish: static func(this: body) -> result<option<trailers>, error-code>;
/// Takes ownership of `body`, and returns an unresolved optional `trailers`.
///
/// This function will trap if a `stream` child is still alive.
finish: static func(this: body) -> future<option<trailers>>;
}

/// Represents an HTTP Request.
Expand Down