@bytecodealliance/preview2-shim 0.16.1 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/nodejs/http.js +2 -0
- package/package.json +1 -1
- package/types/clocks.d.ts +2 -2
- package/types/interfaces/wasi-filesystem-types.d.ts +249 -249
- package/types/interfaces/wasi-http-types.d.ts +376 -376
- package/types/interfaces/wasi-io-error.d.ts +9 -9
- package/types/interfaces/wasi-io-poll.d.ts +12 -12
- package/types/interfaces/wasi-io-streams.d.ts +218 -218
- package/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +21 -21
- package/types/interfaces/wasi-sockets-tcp.d.ts +301 -301
- package/types/interfaces/wasi-sockets-udp.d.ts +276 -276
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export namespace WasiIoError {
|
|
2
|
-
/**
|
|
3
|
-
* Returns a string that is suitable to assist humans in debugging
|
|
4
|
-
* this error.
|
|
5
|
-
*
|
|
6
|
-
* WARNING: The returned string should not be consumed mechanically!
|
|
7
|
-
* It may change across platforms, hosts, or other implementation
|
|
8
|
-
* details. Parsing this string is a major platform-compatibility
|
|
9
|
-
* hazard.
|
|
10
|
-
*/
|
|
11
2
|
export { Error };
|
|
12
3
|
}
|
|
13
4
|
|
|
14
5
|
export class Error {
|
|
6
|
+
/**
|
|
7
|
+
* Returns a string that is suitable to assist humans in debugging
|
|
8
|
+
* this error.
|
|
9
|
+
*
|
|
10
|
+
* WARNING: The returned string should not be consumed mechanically!
|
|
11
|
+
* It may change across platforms, hosts, or other implementation
|
|
12
|
+
* details. Parsing this string is a major platform-compatibility
|
|
13
|
+
* hazard.
|
|
14
|
+
*/
|
|
15
15
|
toDebugString(): string;
|
|
16
16
|
}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
export namespace WasiIoPoll {
|
|
2
|
-
/**
|
|
3
|
-
* Return the readiness of a pollable. This function never blocks.
|
|
4
|
-
*
|
|
5
|
-
* Returns `true` when the pollable is ready, and `false` otherwise.
|
|
6
|
-
*/
|
|
7
2
|
export { Pollable };
|
|
8
|
-
/**
|
|
9
|
-
* `block` returns immediately if the pollable is ready, and otherwise
|
|
10
|
-
* blocks until ready.
|
|
11
|
-
*
|
|
12
|
-
* This function is equivalent to calling `poll.poll` on a list
|
|
13
|
-
* containing only this pollable.
|
|
14
|
-
*/
|
|
15
3
|
/**
|
|
16
4
|
* Poll for completion on a set of pollables.
|
|
17
5
|
*
|
|
@@ -36,6 +24,18 @@ export namespace WasiIoPoll {
|
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
export class Pollable {
|
|
27
|
+
/**
|
|
28
|
+
* Return the readiness of a pollable. This function never blocks.
|
|
29
|
+
*
|
|
30
|
+
* Returns `true` when the pollable is ready, and `false` otherwise.
|
|
31
|
+
*/
|
|
39
32
|
ready(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* `block` returns immediately if the pollable is ready, and otherwise
|
|
35
|
+
* blocks until ready.
|
|
36
|
+
*
|
|
37
|
+
* This function is equivalent to calling `poll.poll` on a list
|
|
38
|
+
* containing only this pollable.
|
|
39
|
+
*/
|
|
40
40
|
block(): void;
|
|
41
41
|
}
|
|
@@ -1,237 +1,237 @@
|
|
|
1
1
|
export namespace WasiIoStreams {
|
|
2
|
-
/**
|
|
3
|
-
* Perform a non-blocking read from the stream.
|
|
4
|
-
*
|
|
5
|
-
* When the source of a `read` is binary data, the bytes from the source
|
|
6
|
-
* are returned verbatim. When the source of a `read` is known to the
|
|
7
|
-
* implementation to be text, bytes containing the UTF-8 encoding of the
|
|
8
|
-
* text are returned.
|
|
9
|
-
*
|
|
10
|
-
* This function returns a list of bytes containing the read data,
|
|
11
|
-
* when successful. The returned list will contain up to `len` bytes;
|
|
12
|
-
* it may return fewer than requested, but not more. The list is
|
|
13
|
-
* empty when no bytes are available for reading at this time. The
|
|
14
|
-
* pollable given by `subscribe` will be ready when more bytes are
|
|
15
|
-
* available.
|
|
16
|
-
*
|
|
17
|
-
* This function fails with a `stream-error` when the operation
|
|
18
|
-
* encounters an error, giving `last-operation-failed`, or when the
|
|
19
|
-
* stream is closed, giving `closed`.
|
|
20
|
-
*
|
|
21
|
-
* When the caller gives a `len` of 0, it represents a request to
|
|
22
|
-
* read 0 bytes. If the stream is still open, this call should
|
|
23
|
-
* succeed and return an empty list, or otherwise fail with `closed`.
|
|
24
|
-
*
|
|
25
|
-
* The `len` parameter is a `u64`, which could represent a list of u8 which
|
|
26
|
-
* is not possible to allocate in wasm32, or not desirable to allocate as
|
|
27
|
-
* as a return value by the callee. The callee may return a list of bytes
|
|
28
|
-
* less than `len` in size while more bytes are available for reading.
|
|
29
|
-
*/
|
|
30
2
|
export { InputStream };
|
|
3
|
+
export { OutputStream };
|
|
4
|
+
}
|
|
5
|
+
import type { Error } from './wasi-io-error.js';
|
|
6
|
+
export { Error };
|
|
7
|
+
import type { Pollable } from './wasi-io-poll.js';
|
|
8
|
+
export { Pollable };
|
|
9
|
+
/**
|
|
10
|
+
* An error for input-stream and output-stream operations.
|
|
11
|
+
*/
|
|
12
|
+
export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
|
|
13
|
+
/**
|
|
14
|
+
* The last operation (a write or flush) failed before completion.
|
|
15
|
+
*
|
|
16
|
+
* More information is available in the `error` payload.
|
|
17
|
+
*/
|
|
18
|
+
export interface StreamErrorLastOperationFailed {
|
|
19
|
+
tag: 'last-operation-failed',
|
|
20
|
+
val: Error,
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The stream is closed: no more input will be accepted by the
|
|
24
|
+
* stream. A closed output-stream will return this error on all
|
|
25
|
+
* future operations.
|
|
26
|
+
*/
|
|
27
|
+
export interface StreamErrorClosed {
|
|
28
|
+
tag: 'closed',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class InputStream {
|
|
31
32
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
* Perform a non-blocking read from the stream.
|
|
34
|
+
*
|
|
35
|
+
* When the source of a `read` is binary data, the bytes from the source
|
|
36
|
+
* are returned verbatim. When the source of a `read` is known to the
|
|
37
|
+
* implementation to be text, bytes containing the UTF-8 encoding of the
|
|
38
|
+
* text are returned.
|
|
39
|
+
*
|
|
40
|
+
* This function returns a list of bytes containing the read data,
|
|
41
|
+
* when successful. The returned list will contain up to `len` bytes;
|
|
42
|
+
* it may return fewer than requested, but not more. The list is
|
|
43
|
+
* empty when no bytes are available for reading at this time. The
|
|
44
|
+
* pollable given by `subscribe` will be ready when more bytes are
|
|
45
|
+
* available.
|
|
46
|
+
*
|
|
47
|
+
* This function fails with a `stream-error` when the operation
|
|
48
|
+
* encounters an error, giving `last-operation-failed`, or when the
|
|
49
|
+
* stream is closed, giving `closed`.
|
|
50
|
+
*
|
|
51
|
+
* When the caller gives a `len` of 0, it represents a request to
|
|
52
|
+
* read 0 bytes. If the stream is still open, this call should
|
|
53
|
+
* succeed and return an empty list, or otherwise fail with `closed`.
|
|
54
|
+
*
|
|
55
|
+
* The `len` parameter is a `u64`, which could represent a list of u8 which
|
|
56
|
+
* is not possible to allocate in wasm32, or not desirable to allocate as
|
|
57
|
+
* as a return value by the callee. The callee may return a list of bytes
|
|
58
|
+
* less than `len` in size while more bytes are available for reading.
|
|
59
|
+
*/
|
|
60
|
+
read(len: bigint): Uint8Array;
|
|
35
61
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*/
|
|
62
|
+
* Read bytes from a stream, after blocking until at least one byte can
|
|
63
|
+
* be read. Except for blocking, behavior is identical to `read`.
|
|
64
|
+
*/
|
|
65
|
+
blockingRead(len: bigint): Uint8Array;
|
|
41
66
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
* Skip bytes from a stream. Returns number of bytes skipped.
|
|
68
|
+
*
|
|
69
|
+
* Behaves identical to `read`, except instead of returning a list
|
|
70
|
+
* of bytes, returns the number of bytes consumed from the stream.
|
|
71
|
+
*/
|
|
72
|
+
skip(len: bigint): bigint;
|
|
45
73
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* Implementations may trap if the `input-stream` is dropped before
|
|
51
|
-
* all derived `pollable`s created with this function are dropped.
|
|
52
|
-
*/
|
|
74
|
+
* Skip bytes from a stream, after blocking until at least one byte
|
|
75
|
+
* can be skipped. Except for blocking behavior, identical to `skip`.
|
|
76
|
+
*/
|
|
77
|
+
blockingSkip(len: bigint): bigint;
|
|
53
78
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
* Create a `pollable` which will resolve once either the specified stream
|
|
80
|
+
* has bytes available to read or the other end of the stream has been
|
|
81
|
+
* closed.
|
|
82
|
+
* The created `pollable` is a child resource of the `input-stream`.
|
|
83
|
+
* Implementations may trap if the `input-stream` is dropped before
|
|
84
|
+
* all derived `pollable`s created with this function are dropped.
|
|
85
|
+
*/
|
|
86
|
+
subscribe(): Pollable;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class OutputStream {
|
|
65
90
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* returns Err(closed) without writing if the stream has closed since
|
|
78
|
-
* the last call to check-write provided a permit.
|
|
79
|
-
*/
|
|
91
|
+
* Check readiness for writing. This function never blocks.
|
|
92
|
+
*
|
|
93
|
+
* Returns the number of bytes permitted for the next call to `write`,
|
|
94
|
+
* or an error. Calling `write` with more bytes than this function has
|
|
95
|
+
* permitted will trap.
|
|
96
|
+
*
|
|
97
|
+
* When this function returns 0 bytes, the `subscribe` pollable will
|
|
98
|
+
* become ready when this function will report at least 1 byte, or an
|
|
99
|
+
* error.
|
|
100
|
+
*/
|
|
101
|
+
checkWrite(): bigint;
|
|
80
102
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
* Perform a write. This function never blocks.
|
|
104
|
+
*
|
|
105
|
+
* When the destination of a `write` is binary data, the bytes from
|
|
106
|
+
* `contents` are written verbatim. When the destination of a `write` is
|
|
107
|
+
* known to the implementation to be text, the bytes of `contents` are
|
|
108
|
+
* transcoded from UTF-8 into the encoding of the destination and then
|
|
109
|
+
* written.
|
|
110
|
+
*
|
|
111
|
+
* Precondition: check-write gave permit of Ok(n) and contents has a
|
|
112
|
+
* length of less than or equal to n. Otherwise, this function will trap.
|
|
113
|
+
*
|
|
114
|
+
* returns Err(closed) without writing if the stream has closed since
|
|
115
|
+
* the last call to check-write provided a permit.
|
|
116
|
+
*/
|
|
117
|
+
write(contents: Uint8Array): void;
|
|
118
|
+
/**
|
|
119
|
+
* Perform a write of up to 4096 bytes, and then flush the stream. Block
|
|
120
|
+
* until all of these operations are complete, or an error occurs.
|
|
121
|
+
*
|
|
122
|
+
* This is a convenience wrapper around the use of `check-write`,
|
|
123
|
+
* `subscribe`, `write`, and `flush`, and is implemented with the
|
|
124
|
+
* following pseudo-code:
|
|
125
|
+
*
|
|
126
|
+
* ```text
|
|
127
|
+
* let pollable = this.subscribe();
|
|
128
|
+
* while !contents.is_empty() {
|
|
129
|
+
* // Wait for the stream to become writable
|
|
130
|
+
* pollable.block();
|
|
131
|
+
* let Ok(n) = this.check-write(); // eliding error handling
|
|
132
|
+
* let len = min(n, contents.len());
|
|
133
|
+
* let (chunk, rest) = contents.split_at(len);
|
|
134
|
+
* this.write(chunk ); // eliding error handling
|
|
135
|
+
* contents = rest;
|
|
136
|
+
* }
|
|
137
|
+
* this.flush();
|
|
138
|
+
* // Wait for completion of `flush`
|
|
139
|
+
* pollable.block();
|
|
140
|
+
* // Check for any errors that arose during `flush`
|
|
141
|
+
* let _ = this.check-write(); // eliding error handling
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
blockingWriteAndFlush(contents: Uint8Array): void;
|
|
118
145
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
146
|
+
* Request to flush buffered output. This function never blocks.
|
|
147
|
+
*
|
|
148
|
+
* This tells the output-stream that the caller intends any buffered
|
|
149
|
+
* output to be flushed. the output which is expected to be flushed
|
|
150
|
+
* is all that has been passed to `write` prior to this call.
|
|
151
|
+
*
|
|
152
|
+
* Upon calling this function, the `output-stream` will not accept any
|
|
153
|
+
* writes (`check-write` will return `ok(0)`) until the flush has
|
|
154
|
+
* completed. The `subscribe` pollable will become ready when the
|
|
155
|
+
* flush has completed and the stream can accept more writes.
|
|
156
|
+
*/
|
|
157
|
+
flush(): void;
|
|
122
158
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*
|
|
128
|
-
* If the stream is closed, this pollable is always ready immediately.
|
|
129
|
-
*
|
|
130
|
-
* The created `pollable` is a child resource of the `output-stream`.
|
|
131
|
-
* Implementations may trap if the `output-stream` is dropped before
|
|
132
|
-
* all derived `pollable`s created with this function are dropped.
|
|
133
|
-
*/
|
|
159
|
+
* Request to flush buffered output, and block until flush completes
|
|
160
|
+
* and stream is ready for writing again.
|
|
161
|
+
*/
|
|
162
|
+
blockingFlush(): void;
|
|
134
163
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
164
|
+
* Create a `pollable` which will resolve once the output-stream
|
|
165
|
+
* is ready for more writing, or an error has occured. When this
|
|
166
|
+
* pollable is ready, `check-write` will return `ok(n)` with n>0, or an
|
|
167
|
+
* error.
|
|
168
|
+
*
|
|
169
|
+
* If the stream is closed, this pollable is always ready immediately.
|
|
170
|
+
*
|
|
171
|
+
* The created `pollable` is a child resource of the `output-stream`.
|
|
172
|
+
* Implementations may trap if the `output-stream` is dropped before
|
|
173
|
+
* all derived `pollable`s created with this function are dropped.
|
|
174
|
+
*/
|
|
175
|
+
subscribe(): Pollable;
|
|
142
176
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
* ```text
|
|
152
|
-
* let pollable = this.subscribe();
|
|
153
|
-
* while num_zeroes != 0 {
|
|
154
|
-
* // Wait for the stream to become writable
|
|
155
|
-
* pollable.block();
|
|
156
|
-
* let Ok(n) = this.check-write(); // eliding error handling
|
|
157
|
-
* let len = min(n, num_zeroes);
|
|
158
|
-
* this.write-zeroes(len); // eliding error handling
|
|
159
|
-
* num_zeroes -= len;
|
|
160
|
-
* }
|
|
161
|
-
* this.flush();
|
|
162
|
-
* // Wait for completion of `flush`
|
|
163
|
-
* pollable.block();
|
|
164
|
-
* // Check for any errors that arose during `flush`
|
|
165
|
-
* let _ = this.check-write(); // eliding error handling
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
/**
|
|
169
|
-
* Read from one stream and write to another.
|
|
170
|
-
*
|
|
171
|
-
* The behavior of splice is equivelant to:
|
|
172
|
-
* 1. calling `check-write` on the `output-stream`
|
|
173
|
-
* 2. calling `read` on the `input-stream` with the smaller of the
|
|
174
|
-
* `check-write` permitted length and the `len` provided to `splice`
|
|
175
|
-
* 3. calling `write` on the `output-stream` with that read data.
|
|
176
|
-
*
|
|
177
|
-
* Any error reported by the call to `check-write`, `read`, or
|
|
178
|
-
* `write` ends the splice and reports that error.
|
|
179
|
-
*
|
|
180
|
-
* This function returns the number of bytes transferred; it may be less
|
|
181
|
-
* than `len`.
|
|
182
|
-
*/
|
|
183
|
-
/**
|
|
184
|
-
* Read from one stream and write to another, with blocking.
|
|
185
|
-
*
|
|
186
|
-
* This is similar to `splice`, except that it blocks until the
|
|
187
|
-
* `output-stream` is ready for writing, and the `input-stream`
|
|
188
|
-
* is ready for reading, before performing the `splice`.
|
|
189
|
-
*/
|
|
190
|
-
}
|
|
191
|
-
import type { Error } from './wasi-io-error.js';
|
|
192
|
-
export { Error };
|
|
193
|
-
import type { Pollable } from './wasi-io-poll.js';
|
|
194
|
-
export { Pollable };
|
|
177
|
+
* Write zeroes to a stream.
|
|
178
|
+
*
|
|
179
|
+
* This should be used precisely like `write` with the exact same
|
|
180
|
+
* preconditions (must use check-write first), but instead of
|
|
181
|
+
* passing a list of bytes, you simply pass the number of zero-bytes
|
|
182
|
+
* that should be written.
|
|
183
|
+
*/
|
|
184
|
+
writeZeroes(len: bigint): void;
|
|
195
185
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
blockingSkip(len: bigint): bigint;
|
|
222
|
-
subscribe(): Pollable;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export class OutputStream {
|
|
226
|
-
checkWrite(): bigint;
|
|
227
|
-
write(contents: Uint8Array): void;
|
|
228
|
-
blockingWriteAndFlush(contents: Uint8Array): void;
|
|
229
|
-
flush(): void;
|
|
230
|
-
blockingFlush(): void;
|
|
231
|
-
subscribe(): Pollable;
|
|
232
|
-
writeZeroes(len: bigint): void;
|
|
186
|
+
* Perform a write of up to 4096 zeroes, and then flush the stream.
|
|
187
|
+
* Block until all of these operations are complete, or an error
|
|
188
|
+
* occurs.
|
|
189
|
+
*
|
|
190
|
+
* This is a convenience wrapper around the use of `check-write`,
|
|
191
|
+
* `subscribe`, `write-zeroes`, and `flush`, and is implemented with
|
|
192
|
+
* the following pseudo-code:
|
|
193
|
+
*
|
|
194
|
+
* ```text
|
|
195
|
+
* let pollable = this.subscribe();
|
|
196
|
+
* while num_zeroes != 0 {
|
|
197
|
+
* // Wait for the stream to become writable
|
|
198
|
+
* pollable.block();
|
|
199
|
+
* let Ok(n) = this.check-write(); // eliding error handling
|
|
200
|
+
* let len = min(n, num_zeroes);
|
|
201
|
+
* this.write-zeroes(len); // eliding error handling
|
|
202
|
+
* num_zeroes -= len;
|
|
203
|
+
* }
|
|
204
|
+
* this.flush();
|
|
205
|
+
* // Wait for completion of `flush`
|
|
206
|
+
* pollable.block();
|
|
207
|
+
* // Check for any errors that arose during `flush`
|
|
208
|
+
* let _ = this.check-write(); // eliding error handling
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
233
211
|
blockingWriteZeroesAndFlush(len: bigint): void;
|
|
212
|
+
/**
|
|
213
|
+
* Read from one stream and write to another.
|
|
214
|
+
*
|
|
215
|
+
* The behavior of splice is equivelant to:
|
|
216
|
+
* 1. calling `check-write` on the `output-stream`
|
|
217
|
+
* 2. calling `read` on the `input-stream` with the smaller of the
|
|
218
|
+
* `check-write` permitted length and the `len` provided to `splice`
|
|
219
|
+
* 3. calling `write` on the `output-stream` with that read data.
|
|
220
|
+
*
|
|
221
|
+
* Any error reported by the call to `check-write`, `read`, or
|
|
222
|
+
* `write` ends the splice and reports that error.
|
|
223
|
+
*
|
|
224
|
+
* This function returns the number of bytes transferred; it may be less
|
|
225
|
+
* than `len`.
|
|
226
|
+
*/
|
|
234
227
|
splice(src: InputStream, len: bigint): bigint;
|
|
228
|
+
/**
|
|
229
|
+
* Read from one stream and write to another, with blocking.
|
|
230
|
+
*
|
|
231
|
+
* This is similar to `splice`, except that it blocks until the
|
|
232
|
+
* `output-stream` is ready for writing, and the `input-stream`
|
|
233
|
+
* is ready for reading, before performing the `splice`.
|
|
234
|
+
*/
|
|
235
235
|
blockingSplice(src: InputStream, len: bigint): bigint;
|
|
236
236
|
}
|
|
237
237
|
|
|
@@ -22,28 +22,7 @@ export namespace WasiSocketsIpNameLookup {
|
|
|
22
22
|
* - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
|
|
23
23
|
*/
|
|
24
24
|
export function resolveAddresses(network: Network, name: string): ResolveAddressStream;
|
|
25
|
-
/**
|
|
26
|
-
* Returns the next address from the resolver.
|
|
27
|
-
*
|
|
28
|
-
* This function should be called multiple times. On each call, it will
|
|
29
|
-
* return the next address in connection order preference. If all
|
|
30
|
-
* addresses have been exhausted, this function returns `none`.
|
|
31
|
-
*
|
|
32
|
-
* This function never returns IPv4-mapped IPv6 addresses.
|
|
33
|
-
*
|
|
34
|
-
* # Typical errors
|
|
35
|
-
* - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
|
|
36
|
-
* - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
|
|
37
|
-
* - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
|
|
38
|
-
* - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
|
|
39
|
-
*/
|
|
40
25
|
export { ResolveAddressStream };
|
|
41
|
-
/**
|
|
42
|
-
* Create a `pollable` which will resolve once the stream is ready for I/O.
|
|
43
|
-
*
|
|
44
|
-
* Note: this function is here for WASI Preview2 only.
|
|
45
|
-
* It's planned to be removed when `future` is natively supported in Preview3.
|
|
46
|
-
*/
|
|
47
26
|
}
|
|
48
27
|
import type { Pollable } from './wasi-io-poll.js';
|
|
49
28
|
export { Pollable };
|
|
@@ -55,6 +34,27 @@ import type { IpAddress } from './wasi-sockets-network.js';
|
|
|
55
34
|
export { IpAddress };
|
|
56
35
|
|
|
57
36
|
export class ResolveAddressStream {
|
|
37
|
+
/**
|
|
38
|
+
* Returns the next address from the resolver.
|
|
39
|
+
*
|
|
40
|
+
* This function should be called multiple times. On each call, it will
|
|
41
|
+
* return the next address in connection order preference. If all
|
|
42
|
+
* addresses have been exhausted, this function returns `none`.
|
|
43
|
+
*
|
|
44
|
+
* This function never returns IPv4-mapped IPv6 addresses.
|
|
45
|
+
*
|
|
46
|
+
* # Typical errors
|
|
47
|
+
* - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
|
|
48
|
+
* - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
|
|
49
|
+
* - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
|
|
50
|
+
* - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
|
|
51
|
+
*/
|
|
58
52
|
resolveNextAddress(): IpAddress | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Create a `pollable` which will resolve once the stream is ready for I/O.
|
|
55
|
+
*
|
|
56
|
+
* Note: this function is here for WASI Preview2 only.
|
|
57
|
+
* It's planned to be removed when `future` is natively supported in Preview3.
|
|
58
|
+
*/
|
|
59
59
|
subscribe(): Pollable;
|
|
60
60
|
}
|