Skip to content

Commit ad500ba

Browse files
authored
Add get-* prefix to getters (#170)
* Add `get-*` prefix * Prefix `header` & `options` as well. * Rename `entries` to `copy-all` to better indicate the associated cost. * Rename `body` to `consume-body` to better communicate that it is not a simple property and has side effects.
1 parent d97efe4 commit ad500ba

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

wit-0.3.0-draft/types.wit

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ interface types {
216216
///
217217
/// The names and values are always returned in the original casing and in
218218
/// the order in which they will be serialized for transport.
219-
entries: func() -> list<tuple<field-name,field-value>>;
219+
copy-all: func() -> list<tuple<field-name,field-value>>;
220220

221221
/// Make a deep copy of the Fields. Equivalent in behavior to calling the
222-
/// `fields` constructor on the return value of `entries`. The resulting
222+
/// `fields` constructor on the return value of `copy-all`. The resulting
223223
/// `fields` is mutable.
224224
clone: func() -> fields;
225225
}
@@ -262,22 +262,22 @@ interface types {
262262
) -> tuple<request, future<result<_, error-code>>>;
263263

264264
/// Get the Method for the Request.
265-
method: func() -> method;
265+
get-method: func() -> method;
266266
/// Set the Method for the Request. Fails if the string present in a
267267
/// `method.other` argument is not a syntactically valid method.
268268
set-method: func(method: method) -> result;
269269

270270
/// Get the combination of the HTTP Path and Query for the Request. When
271271
/// `none`, this represents an empty Path and empty Query.
272-
path-with-query: func() -> option<string>;
272+
get-path-with-query: func() -> option<string>;
273273
/// Set the combination of the HTTP Path and Query for the Request. When
274274
/// `none`, this represents an empty Path and empty Query. Fails is the
275275
/// string given is not a syntactically valid path and query uri component.
276276
set-path-with-query: func(path-with-query: option<string>) -> result;
277277

278278
/// Get the HTTP Related Scheme for the Request. When `none`, the
279279
/// implementation may choose an appropriate default scheme.
280-
scheme: func() -> option<scheme>;
280+
get-scheme: func() -> option<scheme>;
281281
/// Set the HTTP Related Scheme for the Request. When `none`, the
282282
/// implementation may choose an appropriate default scheme. Fails if the
283283
/// string given is not a syntactically valid uri scheme.
@@ -286,7 +286,7 @@ interface types {
286286
/// Get the authority of the Request's target URI. A value of `none` may be used
287287
/// with Related Schemes which do not require an authority. The HTTP and
288288
/// HTTPS schemes always require an authority.
289-
authority: func() -> option<string>;
289+
get-authority: func() -> option<string>;
290290
/// Set the authority of the Request's target URI. A value of `none` may be used
291291
/// with Related Schemes which do not require an authority. The HTTP and
292292
/// HTTPS schemes always require an authority. Fails if the string given is
@@ -301,19 +301,19 @@ interface types {
301301
/// This `request-options` resource is a child: it must be dropped before
302302
/// the parent `request` is dropped, or its ownership is transferred to
303303
/// another component by e.g. `handler.handle`.
304-
options: func() -> option<request-options>;
304+
get-options: func() -> option<request-options>;
305305

306306
/// Get the headers associated with the Request.
307307
///
308308
/// The returned `headers` resource is immutable: `set`, `append`, and
309309
/// `delete` operations will fail with `header-error.immutable`.
310-
headers: func() -> headers;
310+
get-headers: func() -> headers;
311311

312312
/// Get body of the Request.
313313
///
314314
/// Stream returned by this method represents the contents of the body.
315-
/// Once the stream is reported as closed, callers should await the returned future
316-
/// to determine whether the body was received successfully.
315+
/// Once the stream is reported as closed, callers should await the returned
316+
/// future to determine whether the body was received successfully.
317317
/// The future will only resolve after the stream is reported as closed.
318318
///
319319
/// The stream and future returned by this method are children:
@@ -327,8 +327,9 @@ interface types {
327327
/// - a stream or future returned by a previous call to this method is still open
328328
/// - a stream returned by a previous call to this method has reported itself as closed
329329
/// Thus there will always be at most one readable stream open for a given body.
330-
/// Each subsequent stream picks up where the last stream left off, up until it is finished.
331-
body: func() -> result<tuple<stream<u8>, future<result<option<trailers>, error-code>>>>;
330+
/// Each subsequent stream picks up where the previous one left off,
331+
/// continuing until the entire body has been consumed.
332+
consume-body: func() -> result<tuple<stream<u8>, future<result<option<trailers>, error-code>>>>;
332333
}
333334

334335
/// Parameters for making an HTTP Request. Each of these parameters is
@@ -342,15 +343,15 @@ interface types {
342343
constructor();
343344

344345
/// The timeout for the initial connect to the HTTP Server.
345-
connect-timeout: func() -> option<duration>;
346+
get-connect-timeout: func() -> option<duration>;
346347

347348
/// Set the timeout for the initial connect to the HTTP Server. An error
348349
/// return value indicates that this timeout is not supported or that this
349350
/// handle is immutable.
350351
set-connect-timeout: func(duration: option<duration>) -> result<_, request-options-error>;
351352

352353
/// The timeout for receiving the first byte of the Response body.
353-
first-byte-timeout: func() -> option<duration>;
354+
get-first-byte-timeout: func() -> option<duration>;
354355

355356
/// Set the timeout for receiving the first byte of the Response body. An
356357
/// error return value indicates that this timeout is not supported or that
@@ -359,7 +360,7 @@ interface types {
359360

360361
/// The timeout for receiving subsequent chunks of bytes in the Response
361362
/// body stream.
362-
between-bytes-timeout: func() -> option<duration>;
363+
get-between-bytes-timeout: func() -> option<duration>;
363364

364365
/// Set the timeout for receiving subsequent chunks of bytes in the Response
365366
/// body stream. An error return value indicates that this timeout is not
@@ -397,7 +398,7 @@ interface types {
397398
) -> tuple<response, future<result<_, error-code>>>;
398399

399400
/// Get the HTTP Status Code for the Response.
400-
status-code: func() -> status-code;
401+
get-status-code: func() -> status-code;
401402

402403
/// Set the HTTP Status Code for the Response. Fails if the status-code
403404
/// given is not a valid http status code.
@@ -407,13 +408,13 @@ interface types {
407408
///
408409
/// The returned `headers` resource is immutable: `set`, `append`, and
409410
/// `delete` operations will fail with `header-error.immutable`.
410-
headers: func() -> headers;
411+
get-headers: func() -> headers;
411412

412413
/// Get body of the Response.
413414
///
414415
/// Stream returned by this method represents the contents of the body.
415-
/// Once the stream is reported as closed, callers should await the returned future
416-
/// to determine whether the body was received successfully.
416+
/// Once the stream is reported as closed, callers should await the returned
417+
/// future to determine whether the body was received successfully.
417418
/// The future will only resolve after the stream is reported as closed.
418419
///
419420
/// The stream and future returned by this method are children:
@@ -427,7 +428,8 @@ interface types {
427428
/// - a stream or future returned by a previous call to this method is still open
428429
/// - a stream returned by a previous call to this method has reported itself as closed
429430
/// Thus there will always be at most one readable stream open for a given body.
430-
/// Each subsequent stream picks up where the last stream left off, up until it is finished.
431-
body: func() -> result<tuple<stream<u8>, future<result<option<trailers>, error-code>>>>;
431+
/// Each subsequent stream picks up where the previous one left off,
432+
/// continuing until the entire body has been consumed.
433+
consume-body: func() -> result<tuple<stream<u8>, future<result<option<trailers>, error-code>>>>;
432434
}
433435
}

0 commit comments

Comments
 (0)