Skip to content

Add get-* prefix to getters #170

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

Open
wants to merge 4 commits 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
44 changes: 23 additions & 21 deletions wit-0.3.0-draft/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ interface types {
///
/// The names and values are always returned in the original casing and in
/// the order in which they will be serialized for transport.
entries: func() -> list<tuple<field-name,field-value>>;
copy-all: func() -> list<tuple<field-name,field-value>>;

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

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

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

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

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

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

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

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

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

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

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

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

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

/// Get the HTTP Status Code for the Response.
status-code: func() -> status-code;
get-status-code: func() -> status-code;

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

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