diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 185f6a1..e5a9585 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,4 +18,4 @@ jobs: ./wit-deps lock git add -N wit/deps git diff --exit-code - - uses: WebAssembly/wit-abi-up-to-date@v17 + - uses: WebAssembly/wit-abi-up-to-date@v21 diff --git a/imports.md b/imports.md index 6716d29..44eb2c0 100644 --- a/imports.md +++ b/imports.md @@ -2,28 +2,28 @@ -

Import interface wasi:sockets/network@0.2.0

+

Import interface wasi:sockets/network@0.2.0


Types

-

resource network

+

resource network

An opaque resource that represents access to (a subset of) the network. This enables context-based security for networking. There is no need for this to map 1:1 to a physical network interface.

-

enum error-code

+

enum error-code

Error codes.

In theory, every API can return any error code. In practice, API's typically only return the errors documented per API @@ -39,220 +39,220 @@ combined with a couple of errors that are always possible:

Enum Cases
-

enum ip-address-family

+

enum ip-address-family

Enum Cases
-

tuple ipv4-address

+

tuple ipv4-address

Tuple Fields
-

tuple ipv6-address

+

tuple ipv6-address

Tuple Fields
-

variant ip-address

+

variant ip-address

Variant Cases
-

record ipv4-socket-address

+

record ipv4-socket-address

Record Fields
-

record ipv6-socket-address

+

record ipv6-socket-address

Record Fields
-

variant ip-socket-address

+

variant ip-socket-address

Variant Cases
-

Import interface wasi:sockets/instance-network@0.2.0

+

Import interface wasi:sockets/instance-network@0.2.0

This interface provides a value-export of the default network handle..


Types

-

type network

+

type network

network

----

Functions

-

instance-network: func

+

instance-network: func

Get a handle to the default network.

Return values
-

Import interface wasi:io/poll@0.2.0

+

Import interface wasi:io/poll@0.2.0

A poll API intended to let users wait for I/O events on multiple handles at once.


Types

-

resource pollable

+

resource pollable

pollable represents a single I/O event which may be ready, or not.

Functions

-

[method]pollable.ready: func

+

[method]pollable.ready: func

Return the readiness of a pollable. This function never blocks.

Returns true when the pollable is ready, and false otherwise.

Params
Return values
-

[method]pollable.block: func

+

[method]pollable.block: func

block returns immediately if the pollable is ready, and otherwise blocks until ready.

This function is equivalent to calling poll.poll on a list containing only this pollable.

Params
-

poll: func

+

poll: func

Poll for completion on a set of pollables.

This function takes a list of pollables, which identify I/O sources of interest, and waits until one or more of the events is ready for I/O.

@@ -268,56 +268,56 @@ the pollables has an error, it is indicated by marking the source as being reaedy for I/O.

Params
Return values
-

Import interface wasi:sockets/udp@0.2.0

+

Import interface wasi:sockets/udp@0.2.0


Types

-

type pollable

+

type pollable

pollable

-#### `type network` +#### `type network` [`network`](#network)

-#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

-#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

-#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

-#### `record incoming-datagram` +#### `record incoming-datagram`

A received datagram.

Record Fields
-

record outgoing-datagram

+

record outgoing-datagram

A datagram to be sent out.

Record Fields
Params
Return values
-

[method]udp-socket.finish-bind: func

+

[method]udp-socket.finish-bind: func

Params
Return values
-

[method]udp-socket.stream: func

+

[method]udp-socket.stream: func

Set up inbound & outbound communication channels, optionally to a specific peer.

This function only changes the local socket configuration and does not generate any network traffic. On success, the remote-address of the socket is updated. The local-address may be updated as well, @@ -420,14 +420,14 @@ if (remote_address is Some) {

Params
Return values
-

[method]udp-socket.local-address: func

+

[method]udp-socket.local-address: func

Get the current bound address.

POSIX mentions:

@@ -448,13 +448,13 @@ stored in the object pointed to by address is unspecified.

Params
Return values
-

[method]udp-socket.remote-address: func

+

[method]udp-socket.remote-address: func

Get the address the socket is currently streaming to.

Typical errors

Params
Return values
-

[method]udp-socket.address-family: func

+

[method]udp-socket.address-family: func

Whether this is a IPv4 or IPv6 socket.

Equivalent to the SO_DOMAIN socket option.

Params
Return values
-

[method]udp-socket.unicast-hop-limit: func

+

[method]udp-socket.unicast-hop-limit: func

Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.

If the provided value is 0, an invalid-argument error is returned.

Typical errors

@@ -495,23 +495,23 @@ stored in the object pointed to by address is unspecified.

Params
Return values
-

[method]udp-socket.set-unicast-hop-limit: func

+

[method]udp-socket.set-unicast-hop-limit: func

Params
Return values
-

[method]udp-socket.receive-buffer-size: func

+

[method]udp-socket.receive-buffer-size: func

The kernel buffer space reserved for sends/receives on this socket.

If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -523,54 +523,54 @@ I.e. after setting a value, reading the same setting back may return a different

Params
Return values
-

[method]udp-socket.set-receive-buffer-size: func

+

[method]udp-socket.set-receive-buffer-size: func

Params
Return values
-

[method]udp-socket.send-buffer-size: func

+

[method]udp-socket.send-buffer-size: func

Params
Return values
-

[method]udp-socket.set-send-buffer-size: func

+

[method]udp-socket.set-send-buffer-size: func

Params
Return values
-

[method]udp-socket.subscribe: func

+

[method]udp-socket.subscribe: func

Create a pollable which will resolve once the socket is ready for I/O.

Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

Params
Return values
-

[method]incoming-datagram-stream.receive: func

+

[method]incoming-datagram-stream.receive: func

Receive messages on the socket.

This function attempts to receive up to max-results datagrams on the socket without blocking. The returned list may contain fewer elements than requested, but never more.

@@ -598,26 +598,26 @@ This function never returns error(would-block).
Params
Return values
-

[method]incoming-datagram-stream.subscribe: func

+

[method]incoming-datagram-stream.subscribe: func

Create a pollable which will resolve once the stream is ready to receive again.

Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

Params
Return values
-

[method]outgoing-datagram-stream.check-send: func

+

[method]outgoing-datagram-stream.check-send: func

Check readiness for sending. This function never blocks.

Returns the number of datagrams permitted for the next call to send, or an error. Calling send with more datagrams than this function has @@ -628,13 +628,13 @@ error.

Never returns would-block.

Params
Return values
-

[method]outgoing-datagram-stream.send: func

+

[method]outgoing-datagram-stream.send: func

Send messages on the socket.

This function attempts to send all provided datagrams on the socket without blocking and returns how many messages were actually sent (or queued for sending). This function never @@ -669,43 +669,43 @@ either check-send was not called or datagrams contains

Params
Return values
-

[method]outgoing-datagram-stream.subscribe: func

+

[method]outgoing-datagram-stream.subscribe: func

Create a pollable which will resolve once the stream is ready to send again.

Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

Params
Return values
-

Import interface wasi:sockets/udp-create-socket@0.2.0

+

Import interface wasi:sockets/udp-create-socket@0.2.0


Types

-

type network

+

type network

network

-#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

-#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

-#### `type udp-socket` +#### `type udp-socket` [`udp-socket`](#udp_socket)

----

Functions

-

create-udp-socket: func

+

create-udp-socket: func

Create a new UDP socket.

Similar to socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP) in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.

@@ -727,16 +727,16 @@ the socket is effectively an in-memory configuration object, unable to communica
Params
Return values
-

Import interface wasi:io/error@0.2.0

+

Import interface wasi:io/error@0.2.0


Types

-

resource error

+

resource error

A resource which represents some error information.

The only method provided by this resource is to-debug-string, which provides some human-readable information about the error.

@@ -753,7 +753,7 @@ error-code type, using the function

The set of functions which can "downcast" an error into a more concrete type is open.

Functions

-

[method]error.to-debug-string: func

+

[method]error.to-debug-string: func

Returns a string that is suitable to assist humans in debugging this error.

WARNING: The returned string should not be consumed mechanically! @@ -762,42 +762,42 @@ details. Parsing this string is a major platform-compatibility hazard.

Params
Return values
-

Import interface wasi:io/streams@0.2.0

+

Import interface wasi:io/streams@0.2.0

WASI I/O is an I/O abstraction API which is currently focused on providing stream types.

In the future, the component model is expected to add built-in stream types; when it does, they are expected to subsume this API.


Types

-

type error

+

type error

error

-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)

-#### `variant stream-error` +#### `variant stream-error`

An error for input-stream and output-stream operations.

Variant Cases
-

resource input-stream

+

resource input-stream

An input bytestream.

input-streams are non-blocking to the extent practical on underlying platforms. I/O operations always return promptly; if fewer bytes are @@ -805,7 +805,7 @@ promptly available than requested, they return the number of bytes promptly available, which could even be zero. To wait for data to be available, use the subscribe function to obtain a pollable which can be polled for using wasi:io/poll.

-

resource output-stream

+

resource output-stream

An output bytestream.

output-streams are non-blocking to the extent practical on underlying platforms. Except where specified otherwise, I/O operations also @@ -814,7 +814,7 @@ promptly, which could even be zero. To wait for the stream to be ready to accept data, the subscribe function to obtain a pollable which can be polled for using wasi:io/poll.

Functions

-

[method]input-stream.read: func

+

[method]input-stream.read: func

Perform a non-blocking read from the stream.

When the source of a read is binary data, the bytes from the source are returned verbatim. When the source of a read is known to the @@ -838,51 +838,51 @@ as a return value by the callee. The callee may return a list of bytes less than len in size while more bytes are available for reading.

Params
Return values
-

[method]input-stream.blocking-read: func

+

[method]input-stream.blocking-read: func

Read bytes from a stream, after blocking until at least one byte can be read. Except for blocking, behavior is identical to read.

Params
Return values
-

[method]input-stream.skip: func

+

[method]input-stream.skip: func

Skip bytes from a stream. Returns number of bytes skipped.

Behaves identical to read, except instead of returning a list of bytes, returns the number of bytes consumed from the stream.

Params
Return values
-

[method]input-stream.blocking-skip: func

+

[method]input-stream.blocking-skip: func

Skip bytes from a stream, after blocking until at least one byte can be skipped. Except for blocking behavior, identical to skip.

Params
Return values
-

[method]input-stream.subscribe: func

+

[method]input-stream.subscribe: func

Create a pollable which will resolve once either the specified stream has bytes available to read or the other end of the stream has been closed. @@ -891,13 +891,13 @@ Implementations may trap if the input-streampollables created with this function are dropped.

Params
Return values
-

[method]output-stream.check-write: func

+

[method]output-stream.check-write: func

Check readiness for writing. This function never blocks.

Returns the number of bytes permitted for the next call to write, or an error. Calling write with more bytes than this function has @@ -907,13 +907,13 @@ become ready when this function will report at least 1 byte, or an error.

Params
Return values
-

[method]output-stream.write: func

+

[method]output-stream.write: func

Perform a write. This function never blocks.

When the destination of a write is binary data, the bytes from contents are written verbatim. When the destination of a write is @@ -926,14 +926,14 @@ length of less than or equal to n. Otherwise, this function will trap.

the last call to check-write provided a permit.

Params
Return values
-

[method]output-stream.blocking-write-and-flush: func

+

[method]output-stream.blocking-write-and-flush: func

Perform a write of up to 4096 bytes, and then flush the stream. Block until all of these operations are complete, or an error occurs.

This is a convenience wrapper around the use of check-write, @@ -957,14 +957,14 @@ let _ = this.check-write(); // eliding error handling

Params
Return values
-

[method]output-stream.flush: func

+

[method]output-stream.flush: func

Request to flush buffered output. This function never blocks.

This tells the output-stream that the caller intends any buffered output to be flushed. the output which is expected to be flushed @@ -975,24 +975,24 @@ completed. The subscribe pollable will become ready when the flush has completed and the stream can accept more writes.

Params
Return values
-

[method]output-stream.blocking-flush: func

+

[method]output-stream.blocking-flush: func

Request to flush buffered output, and block until flush completes and stream is ready for writing again.

Params
Return values
-

[method]output-stream.subscribe: func

+

[method]output-stream.subscribe: func

Create a pollable which will resolve once the output-stream is ready for more writing, or an error has occured. When this pollable is ready, check-write will return ok(n) with n>0, or an @@ -1003,13 +1003,13 @@ Implementations may trap if the output-streampollables created with this function are dropped.

Params
Return values
-

[method]output-stream.write-zeroes: func

+

[method]output-stream.write-zeroes: func

Write zeroes to a stream.

This should be used precisely like write with the exact same preconditions (must use check-write first), but instead of @@ -1017,14 +1017,14 @@ passing a list of bytes, you simply pass the number of zero-bytes that should be written.

Params
Return values
-

[method]output-stream.blocking-write-zeroes-and-flush: func

+

[method]output-stream.blocking-write-zeroes-and-flush: func

Perform a write of up to 4096 zeroes, and then flush the stream. Block until all of these operations are complete, or an error occurs.

@@ -1048,14 +1048,14 @@ let _ = this.check-write(); // eliding error handling
Params
Return values
-

[method]output-stream.splice: func

+

[method]output-stream.splice: func

Read from one stream and write to another.

The behavior of splice is equivelant to:

    @@ -1070,30 +1070,30 @@ let _ = this.check-write(); // eliding error handling than len.

    Params
    Return values
    -

    [method]output-stream.blocking-splice: func

    +

    [method]output-stream.blocking-splice: func

    Read from one stream and write to another, with blocking.

    This is similar to splice, except that it blocks until the output-stream is ready for writing, and the input-stream is ready for reading, before performing the splice.

    Params
    Return values
    -

    Import interface wasi:clocks/monotonic-clock@0.2.0

    +

    Import interface wasi:clocks/monotonic-clock@0.2.0

    WASI Monotonic Clock is a clock API intended to let users measure elapsed time.

    It is intended to be portable at least between Unix-family platforms and @@ -1103,20 +1103,20 @@ successive reads of the clock will produce non-decreasing values.

    It is intended for measuring elapsed time.


    Types

    -

    type pollable

    +

    type pollable

    pollable

    -#### `type instant` +#### `type instant` `u64`

    An instant in time, in nanoseconds. An instant is relative to an unspecified initial value, and can only be compared to instances from the same monotonic-clock. -

    type duration

    +

    type duration

    u64

    A duration of time, in nanoseconds.


    Functions

    -

    now: func

    +

    now: func

    Read the current value of the clock.

    The clock is monotonic, therefore calling this function repeatedly will produce a sequence of non-decreasing values.

    @@ -1124,80 +1124,80 @@ produce a sequence of non-decreasing values.

    -

    resolution: func

    +

    resolution: func

    Query the resolution of the clock. Returns the duration of time corresponding to a clock tick.

    Return values
    -

    subscribe-instant: func

    +

    subscribe-instant: func

    Create a pollable which will resolve once the specified instant occured.

    Params
    Return values
    -

    subscribe-duration: func

    +

    subscribe-duration: func

    Create a pollable which will resolve once the given duration has elapsed, starting at the time at which this function was called. occured.

    Params
    Return values
    -

    Import interface wasi:sockets/tcp@0.2.0

    +

    Import interface wasi:sockets/tcp@0.2.0


    Types

    -

    type input-stream

    +

    type input-stream

    input-stream

    -#### `type output-stream` +#### `type output-stream` [`output-stream`](#output_stream)

    -#### `type pollable` +#### `type pollable` [`pollable`](#pollable)

    -#### `type duration` +#### `type duration` [`duration`](#duration)

    -#### `type network` +#### `type network` [`network`](#network)

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

    -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

    -#### `enum shutdown-type` +#### `enum shutdown-type`

    Enum Cases
    -

    resource tcp-socket

    +

    resource tcp-socket

    A TCP socket resource.

    The socket can be in one of the following states:

    Params
    Return values
    -

    [method]tcp-socket.finish-bind: func

    +

    [method]tcp-socket.finish-bind: func

    Params
    Return values
    -

    [method]tcp-socket.start-connect: func

    +

    [method]tcp-socket.start-connect: func

    Connect to a remote endpoint.

    On success:

    Params
    Return values
    -

    [method]tcp-socket.finish-listen: func

    +

    [method]tcp-socket.finish-listen: func

    Params
    Return values
    -

    [method]tcp-socket.accept: func

    +

    [method]tcp-socket.accept: func

    Accept a new client socket.

    The returned socket is bound and in the connected state. The following properties are inherited from the listener socket:

      @@ -1410,13 +1410,13 @@ a pair of streams that can be used to read & write to the connection.

    Params
    Return values
    -

    [method]tcp-socket.local-address: func

    +

    [method]tcp-socket.local-address: func

    Get the bound local address.

    POSIX mentions:

    @@ -1437,13 +1437,13 @@ stored in the object pointed to by address is unspecified.

    Params
    Return values
    -

    [method]tcp-socket.remote-address: func

    +

    [method]tcp-socket.remote-address: func

    Get the remote address.

    Typical errors

      @@ -1458,35 +1458,35 @@ stored in the object pointed to by address is unspecified.

    Params
    Return values
    -

    [method]tcp-socket.is-listening: func

    +

    [method]tcp-socket.is-listening: func

    Whether the socket is in the listening state.

    Equivalent to the SO_ACCEPTCONN socket option.

    Params
    Return values
      -
    • bool
    • +
    • bool
    -

    [method]tcp-socket.address-family: func

    +

    [method]tcp-socket.address-family: func

    Whether this is a IPv4 or IPv6 socket.

    Equivalent to the SO_DOMAIN socket option.

    Params
    Return values
    -

    [method]tcp-socket.set-listen-backlog-size: func

    +

    [method]tcp-socket.set-listen-backlog-size: func

    Hints the desired listen queue size. Implementations are free to ignore this.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded.

    @@ -1498,14 +1498,14 @@ Any other value will never cause an error, but it might be silently clamped and/
    Params
    Return values
    -

    [method]tcp-socket.keep-alive-enabled: func

    +

    [method]tcp-socket.keep-alive-enabled: func

    Enables or disables keepalive.

    The keepalive behavior can be adjusted using:

      @@ -1517,23 +1517,23 @@ These properties can be configured while keep-alive-enabled is fals

      Equivalent to the SO_KEEPALIVE socket option.

      Params
      Return values
      -

      [method]tcp-socket.set-keep-alive-enabled: func

      +

      [method]tcp-socket.set-keep-alive-enabled: func

      Params
      Return values
      -

      [method]tcp-socket.keep-alive-idle-time: func

      +

      [method]tcp-socket.keep-alive-idle-time: func

      Amount of time the connection has to be idle before TCP starts sending keepalive packets.

      If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -1545,23 +1545,23 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-keep-alive-idle-time: func

    +

    [method]tcp-socket.set-keep-alive-idle-time: func

    Params
    Return values
    -

    [method]tcp-socket.keep-alive-interval: func

    +

    [method]tcp-socket.keep-alive-interval: func

    The time between keepalive packets.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -1573,23 +1573,23 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-keep-alive-interval: func

    +

    [method]tcp-socket.set-keep-alive-interval: func

    Params
    Return values
    -

    [method]tcp-socket.keep-alive-count: func

    +

    [method]tcp-socket.keep-alive-count: func

    The maximum amount of keepalive packets TCP should send before aborting the connection.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -1601,23 +1601,23 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-keep-alive-count: func

    +

    [method]tcp-socket.set-keep-alive-count: func

    Params
    Return values
    -

    [method]tcp-socket.hop-limit: func

    +

    [method]tcp-socket.hop-limit: func

    Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.

    If the provided value is 0, an invalid-argument error is returned.

    Typical errors

    @@ -1626,23 +1626,23 @@ I.e. after setting a value, reading the same setting back may return a different
    Params
    Return values
    -

    [method]tcp-socket.set-hop-limit: func

    +

    [method]tcp-socket.set-hop-limit: func

    Params
    Return values
    -

    [method]tcp-socket.receive-buffer-size: func

    +

    [method]tcp-socket.receive-buffer-size: func

    The kernel buffer space reserved for sends/receives on this socket.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -1654,42 +1654,42 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-receive-buffer-size: func

    +

    [method]tcp-socket.set-receive-buffer-size: func

    Params
    Return values
    -

    [method]tcp-socket.send-buffer-size: func

    +

    [method]tcp-socket.send-buffer-size: func

    Params
    Return values
    -

    [method]tcp-socket.set-send-buffer-size: func

    +

    [method]tcp-socket.set-send-buffer-size: func

    Params
    Return values
    -

    [method]tcp-socket.subscribe: func

    +

    [method]tcp-socket.subscribe: func

    Create a pollable which can be used to poll for, or block on, completion of any of the asynchronous operations of this socket.

    When finish-bind, finish-listen, finish-connect or accept @@ -1705,13 +1705,13 @@ for more information.

    It's planned to be removed when future is natively supported in Preview3.

    Params
    Return values
    -

    [method]tcp-socket.shutdown: func

    +

    [method]tcp-socket.shutdown: func

    Initiate a graceful shutdown.

    • receive: The socket is not expecting to receive any data from @@ -1738,31 +1738,31 @@ has no effect and returns ok.

    Params
    Return values
    -

    Import interface wasi:sockets/tcp-create-socket@0.2.0

    +

    Import interface wasi:sockets/tcp-create-socket@0.2.0


    Types

    -

    type network

    +

    type network

    network

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

    -#### `type tcp-socket` +#### `type tcp-socket` [`tcp-socket`](#tcp_socket)

    ----

    Functions

    -

    create-tcp-socket: func

    +

    create-tcp-socket: func

    Create a new TCP socket.

    Similar to socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP) in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.

    @@ -1784,31 +1784,31 @@ is called, the socket is effectively an in-memory configuration object, unable t
    Params
    Return values
    -

    Import interface wasi:sockets/ip-name-lookup@0.2.0

    +

    Import interface wasi:sockets/ip-name-lookup@0.2.0


    Types

    -

    type pollable

    +

    type pollable

    pollable

    -#### `type network` +#### `type network` [`network`](#network)

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-address` +#### `type ip-address` [`ip-address`](#ip_address)

    -#### `resource resolve-address-stream` +#### `resource resolve-address-stream`


    Functions

    -

    resolve-addresses: func

    +

    resolve-addresses: func

    Resolve an internet host name to a list of IP addresses.

    Unicode domain names are automatically converted to ASCII using IDNA encoding. If the input is an IP address string, the address is parsed and returned @@ -1830,14 +1830,14 @@ to (asynchronously) fetch the results.

    Params
    Return values
    -

    [method]resolve-address-stream.resolve-next-address: func

    +

    [method]resolve-address-stream.resolve-next-address: func

    Returns the next address from the resolver.

    This function should be called multiple times. On each call, it will return the next address in connection order preference. If all @@ -1852,21 +1852,21 @@ addresses have been exhausted, this function returns none.

    Params
    Return values
    -

    [method]resolve-address-stream.subscribe: func

    +

    [method]resolve-address-stream.subscribe: func

    Create a pollable which will resolve once the stream is ready for I/O.

    Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

    Params
    Return values
    diff --git a/wit/instance-network.wit b/wit/instance-network.wit index e455d0f..5f6e6c1 100644 --- a/wit/instance-network.wit +++ b/wit/instance-network.wit @@ -1,9 +1,11 @@ /// This interface provides a value-export of the default network handle.. +@since(version = 0.2.0) interface instance-network { + @since(version = 0.2.0) use network.{network}; /// Get a handle to the default network. + @since(version = 0.2.0) instance-network: func() -> network; - } diff --git a/wit/ip-name-lookup.wit b/wit/ip-name-lookup.wit index 8e639ec..0368b48 100644 --- a/wit/ip-name-lookup.wit +++ b/wit/ip-name-lookup.wit @@ -1,9 +1,10 @@ - +@since(version = 0.2.0) interface ip-name-lookup { + @since(version = 0.2.0) use wasi:io/poll@0.2.0.{pollable}; + @since(version = 0.2.0) use network.{network, error-code, ip-address}; - /// Resolve an internet host name to a list of IP addresses. /// /// Unicode domain names are automatically converted to ASCII using IDNA encoding. @@ -24,8 +25,10 @@ interface ip-name-lookup { /// - /// - /// - + @since(version = 0.2.0) resolve-addresses: func(network: borrow, name: string) -> result; + @since(version = 0.2.0) resource resolve-address-stream { /// Returns the next address from the resolver. /// @@ -40,12 +43,14 @@ interface ip-name-lookup { /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) + @since(version = 0.2.0) resolve-next-address: func() -> result, error-code>; /// Create a `pollable` which will resolve once the stream is ready for I/O. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } } diff --git a/wit/network.wit b/wit/network.wit index cee7cb3..8c13b34 100644 --- a/wit/network.wit +++ b/wit/network.wit @@ -1,8 +1,9 @@ - +@since(version = 0.2.0) interface network { /// An opaque resource that represents access to (a subset of) the network. /// This enables context-based security for networking. /// There is no need for this to map 1:1 to a physical network interface. + @since(version = 0.2.0) resource network; /// Error codes. @@ -17,6 +18,7 @@ interface network { /// - `concurrency-conflict` /// /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. + @since(version = 0.2.0) enum error-code { /// Unknown error unknown, @@ -61,6 +63,7 @@ interface network { /// Note: this is scheduled to be removed when `future`s are natively supported. would-block, + /// The operation is not valid in the socket's current state. invalid-state, @@ -76,6 +79,7 @@ interface network { /// The remote address is not reachable remote-unreachable, + /// The TCP connection was forcefully rejected connection-refused, @@ -85,10 +89,12 @@ interface network { /// A TCP connection was aborted. connection-aborted, + /// The size of a datagram sent to a UDP socket exceeded the maximum /// supported size. datagram-too-large, + /// Name does not exist or has no suitable associated IP addresses. name-unresolvable, @@ -99,6 +105,7 @@ interface network { permanent-resolver-failure, } + @since(version = 0.2.0) enum ip-address-family { /// Similar to `AF_INET` in POSIX. ipv4, @@ -107,14 +114,18 @@ interface network { ipv6, } + @since(version = 0.2.0) type ipv4-address = tuple; + @since(version = 0.2.0) type ipv6-address = tuple; + @since(version = 0.2.0) variant ip-address { ipv4(ipv4-address), ipv6(ipv6-address), } + @since(version = 0.2.0) record ipv4-socket-address { /// sin_port port: u16, @@ -122,6 +133,7 @@ interface network { address: ipv4-address, } + @since(version = 0.2.0) record ipv6-socket-address { /// sin6_port port: u16, @@ -133,9 +145,9 @@ interface network { scope-id: u32, } + @since(version = 0.2.0) variant ip-socket-address { ipv4(ipv4-socket-address), ipv6(ipv6-socket-address), } - } diff --git a/wit/tcp-create-socket.wit b/wit/tcp-create-socket.wit index c7ddf1f..eedbd30 100644 --- a/wit/tcp-create-socket.wit +++ b/wit/tcp-create-socket.wit @@ -1,6 +1,8 @@ - +@since(version = 0.2.0) interface tcp-create-socket { + @since(version = 0.2.0) use network.{network, error-code, ip-address-family}; + @since(version = 0.2.0) use tcp.{tcp-socket}; /// Create a new TCP socket. @@ -23,5 +25,6 @@ interface tcp-create-socket { /// - /// - /// - + @since(version = 0.2.0) create-tcp-socket: func(address-family: ip-address-family) -> result; } diff --git a/wit/tcp.wit b/wit/tcp.wit index 9aa79bd..e4a6210 100644 --- a/wit/tcp.wit +++ b/wit/tcp.wit @@ -1,10 +1,15 @@ - +@since(version = 0.2.0) interface tcp { + @since(version = 0.2.0) use wasi:io/streams@0.2.0.{input-stream, output-stream}; + @since(version = 0.2.0) use wasi:io/poll@0.2.0.{pollable}; + @since(version = 0.2.0) use wasi:clocks/monotonic-clock@0.2.0.{duration}; + @since(version = 0.2.0) use network.{network, error-code, ip-socket-address, ip-address-family}; + @since(version = 0.2.0) enum shutdown-type { /// Similar to `SHUT_RD` in POSIX. receive, @@ -37,6 +42,7 @@ interface tcp { /// In addition to the general error codes documented on the /// `network::error-code` type, TCP socket methods may always return /// `error(invalid-state)` when in the `closed` state. + @since(version = 0.2.0) resource tcp-socket { /// Bind the socket to a specific network on the provided IP address and port. /// @@ -76,7 +82,9 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; + @since(version = 0.2.0) finish-bind: func() -> result<_, error-code>; /// Connect to a remote endpoint. @@ -121,7 +129,9 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) start-connect: func(network: borrow, remote-address: ip-socket-address) -> result<_, error-code>; + @since(version = 0.2.0) finish-connect: func() -> result, error-code>; /// Start listening for new connections. @@ -149,7 +159,9 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) start-listen: func() -> result<_, error-code>; + @since(version = 0.2.0) finish-listen: func() -> result<_, error-code>; /// Accept a new client socket. @@ -178,6 +190,7 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) accept: func() -> result, error-code>; /// Get the bound local address. @@ -196,6 +209,7 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) local-address: func() -> result; /// Get the remote address. @@ -208,16 +222,19 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) remote-address: func() -> result; /// Whether the socket is in the `listening` state. /// /// Equivalent to the SO_ACCEPTCONN socket option. + @since(version = 0.2.0) is-listening: func() -> bool; /// Whether this is a IPv4 or IPv6 socket. /// /// Equivalent to the SO_DOMAIN socket option. + @since(version = 0.2.0) address-family: func() -> ip-address-family; /// Hints the desired listen queue size. Implementations are free to ignore this. @@ -229,6 +246,7 @@ interface tcp { /// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. /// - `invalid-argument`: (set) The provided value was 0. /// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state. + @since(version = 0.2.0) set-listen-backlog-size: func(value: u64) -> result<_, error-code>; /// Enables or disables keepalive. @@ -240,7 +258,9 @@ interface tcp { /// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true. /// /// Equivalent to the SO_KEEPALIVE socket option. + @since(version = 0.2.0) keep-alive-enabled: func() -> result; + @since(version = 0.2.0) set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; /// Amount of time the connection has to be idle before TCP starts sending keepalive packets. @@ -253,7 +273,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) keep-alive-idle-time: func() -> result; + @since(version = 0.2.0) set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; /// The time between keepalive packets. @@ -266,7 +288,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) keep-alive-interval: func() -> result; + @since(version = 0.2.0) set-keep-alive-interval: func(value: duration) -> result<_, error-code>; /// The maximum amount of keepalive packets TCP should send before aborting the connection. @@ -279,7 +303,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) keep-alive-count: func() -> result; + @since(version = 0.2.0) set-keep-alive-count: func(value: u32) -> result<_, error-code>; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. @@ -288,7 +314,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + @since(version = 0.2.0) hop-limit: func() -> result; + @since(version = 0.2.0) set-hop-limit: func(value: u8) -> result<_, error-code>; /// The kernel buffer space reserved for sends/receives on this socket. @@ -301,9 +329,13 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) receive-buffer-size: func() -> result; + @since(version = 0.2.0) set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + @since(version = 0.2.0) send-buffer-size: func() -> result; + @since(version = 0.2.0) set-send-buffer-size: func(value: u64) -> result<_, error-code>; /// Create a `pollable` which can be used to poll for, or block on, @@ -323,6 +355,7 @@ interface tcp { /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; /// Initiate a graceful shutdown. @@ -348,6 +381,7 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>; } } diff --git a/wit/udp-create-socket.wit b/wit/udp-create-socket.wit index 0482d1f..e8eeacb 100644 --- a/wit/udp-create-socket.wit +++ b/wit/udp-create-socket.wit @@ -1,6 +1,8 @@ - +@since(version = 0.2.0) interface udp-create-socket { + @since(version = 0.2.0) use network.{network, error-code, ip-address-family}; + @since(version = 0.2.0) use udp.{udp-socket}; /// Create a new UDP socket. @@ -23,5 +25,6 @@ interface udp-create-socket { /// - /// - /// - + @since(version = 0.2.0) create-udp-socket: func(address-family: ip-address-family) -> result; } diff --git a/wit/udp.wit b/wit/udp.wit index d987a0a..48e753c 100644 --- a/wit/udp.wit +++ b/wit/udp.wit @@ -1,9 +1,12 @@ - +@since(version = 0.2.0) interface udp { + @since(version = 0.2.0) use wasi:io/poll@0.2.0.{pollable}; + @since(version = 0.2.0) use network.{network, error-code, ip-socket-address, ip-address-family}; /// A received datagram. + @since(version = 0.2.0) record incoming-datagram { /// The payload. /// @@ -19,6 +22,7 @@ interface udp { } /// A datagram to be sent out. + @since(version = 0.2.0) record outgoing-datagram { /// The payload. data: list, @@ -33,9 +37,8 @@ interface udp { remote-address: option, } - - /// A UDP socket handle. + @since(version = 0.2.0) resource udp-socket { /// Bind the socket to a specific network on the provided IP address and port. /// @@ -63,7 +66,9 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; + @since(version = 0.2.0) finish-bind: func() -> result<_, error-code>; /// Set up inbound & outbound communication channels, optionally to a specific peer. @@ -106,6 +111,7 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) %stream: func(remote-address: option) -> result, error-code>; /// Get the current bound address. @@ -124,6 +130,7 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) local-address: func() -> result; /// Get the address the socket is currently streaming to. @@ -136,11 +143,13 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) remote-address: func() -> result; /// Whether this is a IPv4 or IPv6 socket. /// /// Equivalent to the SO_DOMAIN socket option. + @since(version = 0.2.0) address-family: func() -> ip-address-family; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. @@ -149,7 +158,9 @@ interface udp { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + @since(version = 0.2.0) unicast-hop-limit: func() -> result; + @since(version = 0.2.0) set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; /// The kernel buffer space reserved for sends/receives on this socket. @@ -162,18 +173,24 @@ interface udp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) receive-buffer-size: func() -> result; + @since(version = 0.2.0) set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + @since(version = 0.2.0) send-buffer-size: func() -> result; + @since(version = 0.2.0) set-send-buffer-size: func(value: u64) -> result<_, error-code>; /// Create a `pollable` which will resolve once the socket is ready for I/O. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } + @since(version = 0.2.0) resource incoming-datagram-stream { /// Receive messages on the socket. /// @@ -198,15 +215,18 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) receive: func(max-results: u64) -> result, error-code>; /// Create a `pollable` which will resolve once the stream is ready to receive again. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } + @since(version = 0.2.0) resource outgoing-datagram-stream { /// Check readiness for sending. This function never blocks. /// @@ -255,12 +275,14 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) send: func(datagrams: list) -> result; /// Create a `pollable` which will resolve once the stream is ready to send again. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } } diff --git a/wit/world.wit b/wit/world.wit index f8bb92a..a1f7d14 100644 --- a/wit/world.wit +++ b/wit/world.wit @@ -1,11 +1,19 @@ package wasi:sockets@0.2.0; +@since(version = 0.2.0) world imports { + @since(version = 0.2.0) import instance-network; + @since(version = 0.2.0) import network; + @since(version = 0.2.0) import udp; + @since(version = 0.2.0) import udp-create-socket; + @since(version = 0.2.0) import tcp; + @since(version = 0.2.0) import tcp-create-socket; + @since(version = 0.2.0) import ip-name-lookup; }