Skip to content

Commit 061d28f

Browse files
authored
Merge pull request #102 from yoshuawuyts/since-gates
Document per-item versions using `@since` gates
2 parents 983de33 + f9c4df1 commit 061d28f

File tree

10 files changed

+476
-387
lines changed

10 files changed

+476
-387
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
./wit-deps lock
1919
git add -N wit/deps
2020
git diff --exit-code
21-
- uses: WebAssembly/wit-abi-up-to-date@v17
21+
- uses: WebAssembly/wit-abi-up-to-date@v21

imports.md

Lines changed: 375 additions & 375 deletions
Large diffs are not rendered by default.

wit/instance-network.wit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11

22
/// This interface provides a value-export of the default network handle..
3+
@since(version = 0.2.0)
34
interface instance-network {
5+
@since(version = 0.2.0)
46
use network.{network};
57

68
/// Get a handle to the default network.
9+
@since(version = 0.2.0)
710
instance-network: func() -> network;
8-
911
}

wit/ip-name-lookup.wit

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
1+
@since(version = 0.2.0)
22
interface ip-name-lookup {
3+
@since(version = 0.2.0)
34
use wasi:io/poll@0.2.0.{pollable};
5+
@since(version = 0.2.0)
46
use network.{network, error-code, ip-address};
57

6-
78
/// Resolve an internet host name to a list of IP addresses.
89
///
910
/// Unicode domain names are automatically converted to ASCII using IDNA encoding.
@@ -24,8 +25,10 @@ interface ip-name-lookup {
2425
/// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
2526
/// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
2627
/// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
28+
@since(version = 0.2.0)
2729
resolve-addresses: func(network: borrow<network>, name: string) -> result<resolve-address-stream, error-code>;
2830

31+
@since(version = 0.2.0)
2932
resource resolve-address-stream {
3033
/// Returns the next address from the resolver.
3134
///
@@ -40,12 +43,14 @@ interface ip-name-lookup {
4043
/// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
4144
/// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
4245
/// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
46+
@since(version = 0.2.0)
4347
resolve-next-address: func() -> result<option<ip-address>, error-code>;
4448

4549
/// Create a `pollable` which will resolve once the stream is ready for I/O.
4650
///
4751
/// Note: this function is here for WASI Preview2 only.
4852
/// It's planned to be removed when `future` is natively supported in Preview3.
53+
@since(version = 0.2.0)
4954
subscribe: func() -> pollable;
5055
}
5156
}

wit/network.wit

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
1+
@since(version = 0.2.0)
22
interface network {
33
/// An opaque resource that represents access to (a subset of) the network.
44
/// This enables context-based security for networking.
55
/// There is no need for this to map 1:1 to a physical network interface.
6+
@since(version = 0.2.0)
67
resource network;
78

89
/// Error codes.
@@ -17,6 +18,7 @@ interface network {
1718
/// - `concurrency-conflict`
1819
///
1920
/// See each individual API for what the POSIX equivalents are. They sometimes differ per API.
21+
@since(version = 0.2.0)
2022
enum error-code {
2123
/// Unknown error
2224
unknown,
@@ -61,6 +63,7 @@ interface network {
6163
/// Note: this is scheduled to be removed when `future`s are natively supported.
6264
would-block,
6365

66+
6467
/// The operation is not valid in the socket's current state.
6568
invalid-state,
6669

@@ -76,6 +79,7 @@ interface network {
7679
/// The remote address is not reachable
7780
remote-unreachable,
7881

82+
7983
/// The TCP connection was forcefully rejected
8084
connection-refused,
8185

@@ -85,10 +89,12 @@ interface network {
8589
/// A TCP connection was aborted.
8690
connection-aborted,
8791

92+
8893
/// The size of a datagram sent to a UDP socket exceeded the maximum
8994
/// supported size.
9095
datagram-too-large,
9196

97+
9298
/// Name does not exist or has no suitable associated IP addresses.
9399
name-unresolvable,
94100

@@ -99,6 +105,7 @@ interface network {
99105
permanent-resolver-failure,
100106
}
101107

108+
@since(version = 0.2.0)
102109
enum ip-address-family {
103110
/// Similar to `AF_INET` in POSIX.
104111
ipv4,
@@ -107,21 +114,26 @@ interface network {
107114
ipv6,
108115
}
109116

117+
@since(version = 0.2.0)
110118
type ipv4-address = tuple<u8, u8, u8, u8>;
119+
@since(version = 0.2.0)
111120
type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;
112121

122+
@since(version = 0.2.0)
113123
variant ip-address {
114124
ipv4(ipv4-address),
115125
ipv6(ipv6-address),
116126
}
117127

128+
@since(version = 0.2.0)
118129
record ipv4-socket-address {
119130
/// sin_port
120131
port: u16,
121132
/// sin_addr
122133
address: ipv4-address,
123134
}
124135

136+
@since(version = 0.2.0)
125137
record ipv6-socket-address {
126138
/// sin6_port
127139
port: u16,
@@ -133,9 +145,9 @@ interface network {
133145
scope-id: u32,
134146
}
135147

148+
@since(version = 0.2.0)
136149
variant ip-socket-address {
137150
ipv4(ipv4-socket-address),
138151
ipv6(ipv6-socket-address),
139152
}
140-
141153
}

wit/tcp-create-socket.wit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
1+
@since(version = 0.2.0)
22
interface tcp-create-socket {
3+
@since(version = 0.2.0)
34
use network.{network, error-code, ip-address-family};
5+
@since(version = 0.2.0)
46
use tcp.{tcp-socket};
57

68
/// Create a new TCP socket.
@@ -23,5 +25,6 @@ interface tcp-create-socket {
2325
/// - <https://man7.org/linux/man-pages/man2/socket.2.html>
2426
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
2527
/// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
28+
@since(version = 0.2.0)
2629
create-tcp-socket: func(address-family: ip-address-family) -> result<tcp-socket, error-code>;
2730
}

wit/tcp.wit

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
1+
@since(version = 0.2.0)
22
interface tcp {
3+
@since(version = 0.2.0)
34
use wasi:io/streams@0.2.0.{input-stream, output-stream};
5+
@since(version = 0.2.0)
46
use wasi:io/poll@0.2.0.{pollable};
7+
@since(version = 0.2.0)
58
use wasi:clocks/monotonic-clock@0.2.0.{duration};
9+
@since(version = 0.2.0)
610
use network.{network, error-code, ip-socket-address, ip-address-family};
711

12+
@since(version = 0.2.0)
813
enum shutdown-type {
914
/// Similar to `SHUT_RD` in POSIX.
1015
receive,
@@ -37,6 +42,7 @@ interface tcp {
3742
/// In addition to the general error codes documented on the
3843
/// `network::error-code` type, TCP socket methods may always return
3944
/// `error(invalid-state)` when in the `closed` state.
45+
@since(version = 0.2.0)
4046
resource tcp-socket {
4147
/// Bind the socket to a specific network on the provided IP address and port.
4248
///
@@ -76,7 +82,9 @@ interface tcp {
7682
/// - <https://man7.org/linux/man-pages/man2/bind.2.html>
7783
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
7884
/// - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
85+
@since(version = 0.2.0)
7986
start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-code>;
87+
@since(version = 0.2.0)
8088
finish-bind: func() -> result<_, error-code>;
8189

8290
/// Connect to a remote endpoint.
@@ -121,7 +129,9 @@ interface tcp {
121129
/// - <https://man7.org/linux/man-pages/man2/connect.2.html>
122130
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
123131
/// - <https://man.freebsd.org/cgi/man.cgi?connect>
132+
@since(version = 0.2.0)
124133
start-connect: func(network: borrow<network>, remote-address: ip-socket-address) -> result<_, error-code>;
134+
@since(version = 0.2.0)
125135
finish-connect: func() -> result<tuple<input-stream, output-stream>, error-code>;
126136

127137
/// Start listening for new connections.
@@ -149,7 +159,9 @@ interface tcp {
149159
/// - <https://man7.org/linux/man-pages/man2/listen.2.html>
150160
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen>
151161
/// - <https://man.freebsd.org/cgi/man.cgi?query=listen&sektion=2>
162+
@since(version = 0.2.0)
152163
start-listen: func() -> result<_, error-code>;
164+
@since(version = 0.2.0)
153165
finish-listen: func() -> result<_, error-code>;
154166

155167
/// Accept a new client socket.
@@ -178,6 +190,7 @@ interface tcp {
178190
/// - <https://man7.org/linux/man-pages/man2/accept.2.html>
179191
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept>
180192
/// - <https://man.freebsd.org/cgi/man.cgi?query=accept&sektion=2>
193+
@since(version = 0.2.0)
181194
accept: func() -> result<tuple<tcp-socket, input-stream, output-stream>, error-code>;
182195

183196
/// Get the bound local address.
@@ -196,6 +209,7 @@ interface tcp {
196209
/// - <https://man7.org/linux/man-pages/man2/getsockname.2.html>
197210
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
198211
/// - <https://man.freebsd.org/cgi/man.cgi?getsockname>
212+
@since(version = 0.2.0)
199213
local-address: func() -> result<ip-socket-address, error-code>;
200214

201215
/// Get the remote address.
@@ -208,16 +222,19 @@ interface tcp {
208222
/// - <https://man7.org/linux/man-pages/man2/getpeername.2.html>
209223
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
210224
/// - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
225+
@since(version = 0.2.0)
211226
remote-address: func() -> result<ip-socket-address, error-code>;
212227

213228
/// Whether the socket is in the `listening` state.
214229
///
215230
/// Equivalent to the SO_ACCEPTCONN socket option.
231+
@since(version = 0.2.0)
216232
is-listening: func() -> bool;
217233

218234
/// Whether this is a IPv4 or IPv6 socket.
219235
///
220236
/// Equivalent to the SO_DOMAIN socket option.
237+
@since(version = 0.2.0)
221238
address-family: func() -> ip-address-family;
222239

223240
/// Hints the desired listen queue size. Implementations are free to ignore this.
@@ -229,6 +246,7 @@ interface tcp {
229246
/// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen.
230247
/// - `invalid-argument`: (set) The provided value was 0.
231248
/// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state.
249+
@since(version = 0.2.0)
232250
set-listen-backlog-size: func(value: u64) -> result<_, error-code>;
233251

234252
/// Enables or disables keepalive.
@@ -240,7 +258,9 @@ interface tcp {
240258
/// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true.
241259
///
242260
/// Equivalent to the SO_KEEPALIVE socket option.
261+
@since(version = 0.2.0)
243262
keep-alive-enabled: func() -> result<bool, error-code>;
263+
@since(version = 0.2.0)
244264
set-keep-alive-enabled: func(value: bool) -> result<_, error-code>;
245265

246266
/// Amount of time the connection has to be idle before TCP starts sending keepalive packets.
@@ -253,7 +273,9 @@ interface tcp {
253273
///
254274
/// # Typical errors
255275
/// - `invalid-argument`: (set) The provided value was 0.
276+
@since(version = 0.2.0)
256277
keep-alive-idle-time: func() -> result<duration, error-code>;
278+
@since(version = 0.2.0)
257279
set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>;
258280

259281
/// The time between keepalive packets.
@@ -266,7 +288,9 @@ interface tcp {
266288
///
267289
/// # Typical errors
268290
/// - `invalid-argument`: (set) The provided value was 0.
291+
@since(version = 0.2.0)
269292
keep-alive-interval: func() -> result<duration, error-code>;
293+
@since(version = 0.2.0)
270294
set-keep-alive-interval: func(value: duration) -> result<_, error-code>;
271295

272296
/// The maximum amount of keepalive packets TCP should send before aborting the connection.
@@ -279,7 +303,9 @@ interface tcp {
279303
///
280304
/// # Typical errors
281305
/// - `invalid-argument`: (set) The provided value was 0.
306+
@since(version = 0.2.0)
282307
keep-alive-count: func() -> result<u32, error-code>;
308+
@since(version = 0.2.0)
283309
set-keep-alive-count: func(value: u32) -> result<_, error-code>;
284310

285311
/// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
@@ -288,7 +314,9 @@ interface tcp {
288314
///
289315
/// # Typical errors
290316
/// - `invalid-argument`: (set) The TTL value must be 1 or higher.
317+
@since(version = 0.2.0)
291318
hop-limit: func() -> result<u8, error-code>;
319+
@since(version = 0.2.0)
292320
set-hop-limit: func(value: u8) -> result<_, error-code>;
293321

294322
/// The kernel buffer space reserved for sends/receives on this socket.
@@ -301,9 +329,13 @@ interface tcp {
301329
///
302330
/// # Typical errors
303331
/// - `invalid-argument`: (set) The provided value was 0.
332+
@since(version = 0.2.0)
304333
receive-buffer-size: func() -> result<u64, error-code>;
334+
@since(version = 0.2.0)
305335
set-receive-buffer-size: func(value: u64) -> result<_, error-code>;
336+
@since(version = 0.2.0)
306337
send-buffer-size: func() -> result<u64, error-code>;
338+
@since(version = 0.2.0)
307339
set-send-buffer-size: func(value: u64) -> result<_, error-code>;
308340

309341
/// Create a `pollable` which can be used to poll for, or block on,
@@ -323,6 +355,7 @@ interface tcp {
323355
///
324356
/// Note: this function is here for WASI Preview2 only.
325357
/// It's planned to be removed when `future` is natively supported in Preview3.
358+
@since(version = 0.2.0)
326359
subscribe: func() -> pollable;
327360

328361
/// Initiate a graceful shutdown.
@@ -348,6 +381,7 @@ interface tcp {
348381
/// - <https://man7.org/linux/man-pages/man2/shutdown.2.html>
349382
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown>
350383
/// - <https://man.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2>
384+
@since(version = 0.2.0)
351385
shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>;
352386
}
353387
}

wit/udp-create-socket.wit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
1+
@since(version = 0.2.0)
22
interface udp-create-socket {
3+
@since(version = 0.2.0)
34
use network.{network, error-code, ip-address-family};
5+
@since(version = 0.2.0)
46
use udp.{udp-socket};
57

68
/// Create a new UDP socket.
@@ -23,5 +25,6 @@ interface udp-create-socket {
2325
/// - <https://man7.org/linux/man-pages/man2/socket.2.html>
2426
/// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
2527
/// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
28+
@since(version = 0.2.0)
2629
create-udp-socket: func(address-family: ip-address-family) -> result<udp-socket, error-code>;
2730
}

0 commit comments

Comments
 (0)