Skip to content

Commit a9ef33e

Browse files
committed
feat(p3): model body after stream<u8, trailers, error-code>
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent eac8416 commit a9ef33e

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

wit-0.3.0-draft/types.wit

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -240,27 +240,18 @@ interface types {
240240
/// trailers at any given time.
241241
resource body {
242242

243-
/// Construct a new `body` with the specified stream.
243+
/// Construct a new `body` with the specified stream and `finish` future.
244244
///
245-
/// This function returns a future, which will resolve
246-
/// to an error code if transmitting stream data fails.
245+
/// The `finish` future must resolve to a result once `stream` has finished.
247246
///
248-
/// The returned future resolves to success once body stream
249-
/// is fully transmitted.
250-
new: static func(
251-
%stream: stream<u8>,
252-
) -> tuple<body, future<result<_, error-code>>>;
253-
254-
/// Construct a new `body` with the specified stream and trailers.
255-
///
256-
/// This function returns a future, which will resolve
257-
/// to an error code if transmitting stream data or trailers fails.
247+
/// This function returns a future, which will resolve to an error code if
248+
/// transmitting of the request or response this body is a part of fails.
258249
///
259-
/// The returned future resolves to success once body stream and trailers
260-
/// are fully transmitted.
261-
new-with-trailers: static func(
250+
/// The returned future resolves to success once request or response this
251+
/// body is a part of is fully transmitted.
252+
new: static func(
262253
%stream: stream<u8>,
263-
trailers: future<trailers>
254+
finish: future<result<option<trailers>, error-code>>,
264255
) -> tuple<body, future<result<_, error-code>>>;
265256

266257
/// Returns the contents of the body, as a stream of bytes.
@@ -298,8 +289,7 @@ interface types {
298289
/// `none` values for `path-with-query`, `scheme`, and `authority`.
299290
///
300291
/// * `headers` is the HTTP Headers for the Response.
301-
/// * `body` is the optional contents of the body, possibly including
302-
/// trailers.
292+
/// * `body` is the contents of the body, possibly including trailers.
303293
/// * `options` is optional `request-options` to be used if the request is
304294
/// sent over a network connection.
305295
///
@@ -310,7 +300,7 @@ interface types {
310300
/// to reject invalid constructions of `request`.
311301
constructor(
312302
headers: headers,
313-
body: option<body>,
303+
body: body,
314304
options: option<request-options>
315305
);
316306

@@ -424,11 +414,10 @@ interface types {
424414
/// `set-status-code` method.
425415
///
426416
/// * `headers` is the HTTP Headers for the Response.
427-
/// * `body` is the optional contents of the body, possibly including
428-
/// trailers.
417+
/// * `body` is the contents of the body, possibly including trailers.
429418
constructor(
430419
headers: headers,
431-
body: option<body>,
420+
body: body,
432421
);
433422

434423
/// Get the HTTP Status Code for the Response.

0 commit comments

Comments
 (0)