@bytecodealliance/preview2-shim 0.0.13 → 0.0.14
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/README.md +2 -2
- package/lib/browser/cli.js +21 -6
- package/lib/browser/filesystem.js +204 -20
- package/lib/browser/http.js +4 -7
- package/lib/browser/io.js +76 -17
- package/lib/browser/logging.js +2 -2
- package/lib/browser/poll.js +48 -4
- package/lib/http/error.js +1 -1
- package/lib/http/make-request.js +3 -2
- package/lib/http/wasi-http.js +52 -40
- package/lib/nodejs/cli.js +17 -7
- package/lib/nodejs/http.js +4 -7
- package/lib/nodejs/logging.js +2 -2
- package/package.json +1 -1
- package/types/exports/wasi-cli-environment.d.ts +22 -0
- package/types/exports/wasi-cli-exit.d.ts +7 -0
- package/types/exports/wasi-cli-run.d.ts +6 -0
- package/types/exports/wasi-cli-stderr.d.ts +5 -0
- package/types/exports/wasi-cli-stdin.d.ts +5 -0
- package/types/exports/wasi-cli-stdout.d.ts +5 -0
- package/types/exports/wasi-cli-terminal-input.d.ts +13 -0
- package/types/exports/wasi-cli-terminal-output.d.ts +13 -0
- package/types/exports/wasi-cli-terminal-stderr.d.ts +9 -0
- package/types/exports/wasi-cli-terminal-stdin.d.ts +9 -0
- package/types/exports/wasi-cli-terminal-stdout.d.ts +9 -0
- package/types/exports/wasi-clocks-monotonic-clock.d.ts +24 -0
- package/types/exports/wasi-clocks-timezone.d.ts +71 -0
- package/types/exports/wasi-clocks-wall-clock.d.ts +31 -0
- package/types/exports/wasi-filesystem-preopens.d.ts +8 -0
- package/types/exports/wasi-filesystem-types.d.ts +843 -0
- package/types/exports/wasi-http-incoming-handler.d.ts +7 -0
- package/types/exports/wasi-http-outgoing-handler.d.ts +9 -0
- package/types/exports/wasi-http-types.d.ts +118 -0
- package/types/exports/wasi-io-streams.d.ts +220 -0
- package/types/exports/wasi-poll-poll.d.ts +39 -0
- package/types/exports/wasi-random-insecure-seed.d.ts +22 -0
- package/types/exports/wasi-random-insecure.d.ts +20 -0
- package/types/exports/wasi-random-random.d.ts +22 -0
- package/types/exports/wasi-sockets-instance-network.d.ts +8 -0
- package/types/exports/wasi-sockets-ip-name-lookup.d.ts +76 -0
- package/types/exports/wasi-sockets-network.d.ts +180 -0
- package/types/exports/wasi-sockets-tcp-create-socket.d.ts +33 -0
- package/types/exports/wasi-sockets-tcp.d.ts +285 -0
- package/types/exports/wasi-sockets-udp-create-socket.d.ts +33 -0
- package/types/exports/wasi-sockets-udp.d.ts +228 -0
- package/types/imports/wasi-cli-environment.d.ts +22 -0
- package/types/imports/wasi-cli-exit.d.ts +7 -0
- package/types/imports/wasi-cli-stderr.d.ts +5 -0
- package/types/imports/wasi-cli-stdin.d.ts +5 -0
- package/types/imports/wasi-cli-stdout.d.ts +5 -0
- package/types/imports/wasi-cli-terminal-input.d.ts +13 -0
- package/types/imports/wasi-cli-terminal-output.d.ts +13 -0
- package/types/imports/wasi-cli-terminal-stderr.d.ts +9 -0
- package/types/imports/wasi-cli-terminal-stdin.d.ts +9 -0
- package/types/imports/wasi-cli-terminal-stdout.d.ts +9 -0
- package/types/imports/wasi-clocks-monotonic-clock.d.ts +24 -0
- package/types/imports/wasi-clocks-timezone.d.ts +71 -0
- package/types/imports/wasi-clocks-wall-clock.d.ts +31 -0
- package/types/imports/wasi-filesystem-preopens.d.ts +8 -0
- package/types/imports/wasi-filesystem-types.d.ts +843 -0
- package/types/imports/wasi-http-outgoing-handler.d.ts +9 -0
- package/types/imports/wasi-http-types.d.ts +118 -0
- package/types/imports/wasi-io-streams.d.ts +220 -0
- package/types/imports/wasi-poll-poll.d.ts +39 -0
- package/types/imports/wasi-random-insecure-seed.d.ts +22 -0
- package/types/imports/wasi-random-insecure.d.ts +20 -0
- package/types/imports/wasi-random-random.d.ts +22 -0
- package/types/imports/wasi-sockets-instance-network.d.ts +8 -0
- package/types/imports/wasi-sockets-ip-name-lookup.d.ts +76 -0
- package/types/imports/wasi-sockets-network.d.ts +180 -0
- package/types/imports/wasi-sockets-tcp-create-socket.d.ts +33 -0
- package/types/imports/wasi-sockets-tcp.d.ts +285 -0
- package/types/imports/wasi-sockets-udp-create-socket.d.ts +33 -0
- package/types/imports/wasi-sockets-udp.d.ts +228 -0
- package/types/wasi-cli-command.d.ts +29 -0
- package/types/wasi-http-proxy.d.ts +13 -0
|
@@ -0,0 +1,843 @@
|
|
|
1
|
+
export namespace WasiFilesystemTypes {
|
|
2
|
+
/**
|
|
3
|
+
* Return a stream for reading from a file, if available.
|
|
4
|
+
*
|
|
5
|
+
* May fail with an error-code describing why the file cannot be read.
|
|
6
|
+
*
|
|
7
|
+
* Multiple read, write, and append streams may be active on the same open
|
|
8
|
+
* file and they do not interfere with each other.
|
|
9
|
+
*
|
|
10
|
+
* Note: This allows using `read-stream`, which is similar to `read` in POSIX.
|
|
11
|
+
*/
|
|
12
|
+
export function readViaStream(this_: Descriptor, offset: Filesize): InputStream;
|
|
13
|
+
/**
|
|
14
|
+
* Return a stream for writing to a file, if available.
|
|
15
|
+
*
|
|
16
|
+
* May fail with an error-code describing why the file cannot be written.
|
|
17
|
+
*
|
|
18
|
+
* Note: This allows using `write-stream`, which is similar to `write` in
|
|
19
|
+
* POSIX.
|
|
20
|
+
*/
|
|
21
|
+
export function writeViaStream(this_: Descriptor, offset: Filesize): OutputStream;
|
|
22
|
+
/**
|
|
23
|
+
* Return a stream for appending to a file, if available.
|
|
24
|
+
*
|
|
25
|
+
* May fail with an error-code describing why the file cannot be appended.
|
|
26
|
+
*
|
|
27
|
+
* Note: This allows using `write-stream`, which is similar to `write` with
|
|
28
|
+
* `O_APPEND` in in POSIX.
|
|
29
|
+
*/
|
|
30
|
+
export function appendViaStream(this_: Descriptor): OutputStream;
|
|
31
|
+
/**
|
|
32
|
+
* Provide file advisory information on a descriptor.
|
|
33
|
+
*
|
|
34
|
+
* This is similar to `posix_fadvise` in POSIX.
|
|
35
|
+
*/
|
|
36
|
+
export function advise(this_: Descriptor, offset: Filesize, length: Filesize, advice: Advice): void;
|
|
37
|
+
/**
|
|
38
|
+
* Synchronize the data of a file to disk.
|
|
39
|
+
*
|
|
40
|
+
* This function succeeds with no effect if the file descriptor is not
|
|
41
|
+
* opened for writing.
|
|
42
|
+
*
|
|
43
|
+
* Note: This is similar to `fdatasync` in POSIX.
|
|
44
|
+
*/
|
|
45
|
+
export function syncData(this_: Descriptor): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get flags associated with a descriptor.
|
|
48
|
+
*
|
|
49
|
+
* Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
|
|
50
|
+
*
|
|
51
|
+
* Note: This returns the value that was the `fs_flags` value returned
|
|
52
|
+
* from `fdstat_get` in earlier versions of WASI.
|
|
53
|
+
*/
|
|
54
|
+
export function getFlags(this_: Descriptor): DescriptorFlags;
|
|
55
|
+
/**
|
|
56
|
+
* Get the dynamic type of a descriptor.
|
|
57
|
+
*
|
|
58
|
+
* Note: This returns the same value as the `type` field of the `fd-stat`
|
|
59
|
+
* returned by `stat`, `stat-at` and similar.
|
|
60
|
+
*
|
|
61
|
+
* Note: This returns similar flags to the `st_mode & S_IFMT` value provided
|
|
62
|
+
* by `fstat` in POSIX.
|
|
63
|
+
*
|
|
64
|
+
* Note: This returns the value that was the `fs_filetype` value returned
|
|
65
|
+
* from `fdstat_get` in earlier versions of WASI.
|
|
66
|
+
*/
|
|
67
|
+
export function getType(this_: Descriptor): DescriptorType;
|
|
68
|
+
/**
|
|
69
|
+
* Adjust the size of an open file. If this increases the file's size, the
|
|
70
|
+
* extra bytes are filled with zeros.
|
|
71
|
+
*
|
|
72
|
+
* Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
|
|
73
|
+
*/
|
|
74
|
+
export function setSize(this_: Descriptor, size: Filesize): void;
|
|
75
|
+
/**
|
|
76
|
+
* Adjust the timestamps of an open file or directory.
|
|
77
|
+
*
|
|
78
|
+
* Note: This is similar to `futimens` in POSIX.
|
|
79
|
+
*
|
|
80
|
+
* Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
|
|
81
|
+
*/
|
|
82
|
+
export function setTimes(this_: Descriptor, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
|
|
83
|
+
/**
|
|
84
|
+
* Read from a descriptor, without using and updating the descriptor's offset.
|
|
85
|
+
*
|
|
86
|
+
* This function returns a list of bytes containing the data that was
|
|
87
|
+
* read, along with a bool which, when true, indicates that the end of the
|
|
88
|
+
* file was reached. The returned list will contain up to `length` bytes; it
|
|
89
|
+
* may return fewer than requested, if the end of the file is reached or
|
|
90
|
+
* if the I/O operation is interrupted.
|
|
91
|
+
*
|
|
92
|
+
* In the future, this may change to return a `stream<u8, error-code>`.
|
|
93
|
+
*
|
|
94
|
+
* Note: This is similar to `pread` in POSIX.
|
|
95
|
+
*/
|
|
96
|
+
export function read(this_: Descriptor, length: Filesize, offset: Filesize): [Uint8Array, boolean];
|
|
97
|
+
/**
|
|
98
|
+
* Write to a descriptor, without using and updating the descriptor's offset.
|
|
99
|
+
*
|
|
100
|
+
* It is valid to write past the end of a file; the file is extended to the
|
|
101
|
+
* extent of the write, with bytes between the previous end and the start of
|
|
102
|
+
* the write set to zero.
|
|
103
|
+
*
|
|
104
|
+
* In the future, this may change to take a `stream<u8, error-code>`.
|
|
105
|
+
*
|
|
106
|
+
* Note: This is similar to `pwrite` in POSIX.
|
|
107
|
+
*/
|
|
108
|
+
export function write(this_: Descriptor, buffer: Uint8Array | ArrayBuffer, offset: Filesize): Filesize;
|
|
109
|
+
/**
|
|
110
|
+
* Read directory entries from a directory.
|
|
111
|
+
*
|
|
112
|
+
* On filesystems where directories contain entries referring to themselves
|
|
113
|
+
* and their parents, often named `.` and `..` respectively, these entries
|
|
114
|
+
* are omitted.
|
|
115
|
+
*
|
|
116
|
+
* This always returns a new stream which starts at the beginning of the
|
|
117
|
+
* directory. Multiple streams may be active on the same directory, and they
|
|
118
|
+
* do not interfere with each other.
|
|
119
|
+
*/
|
|
120
|
+
export function readDirectory(this_: Descriptor): DirectoryEntryStream;
|
|
121
|
+
/**
|
|
122
|
+
* Synchronize the data and metadata of a file to disk.
|
|
123
|
+
*
|
|
124
|
+
* This function succeeds with no effect if the file descriptor is not
|
|
125
|
+
* opened for writing.
|
|
126
|
+
*
|
|
127
|
+
* Note: This is similar to `fsync` in POSIX.
|
|
128
|
+
*/
|
|
129
|
+
export function sync(this_: Descriptor): void;
|
|
130
|
+
/**
|
|
131
|
+
* Create a directory.
|
|
132
|
+
*
|
|
133
|
+
* Note: This is similar to `mkdirat` in POSIX.
|
|
134
|
+
*/
|
|
135
|
+
export function createDirectoryAt(this_: Descriptor, path: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Return the attributes of an open file or directory.
|
|
138
|
+
*
|
|
139
|
+
* Note: This is similar to `fstat` in POSIX, except that it does not return
|
|
140
|
+
* device and inode information. For testing whether two descriptors refer to
|
|
141
|
+
* the same underlying filesystem object, use `is-same-object`. To obtain
|
|
142
|
+
* additional data that can be used do determine whether a file has been
|
|
143
|
+
* modified, use `metadata-hash`.
|
|
144
|
+
*
|
|
145
|
+
* Note: This was called `fd_filestat_get` in earlier versions of WASI.
|
|
146
|
+
*/
|
|
147
|
+
export function stat(this_: Descriptor): DescriptorStat;
|
|
148
|
+
/**
|
|
149
|
+
* Return the attributes of a file or directory.
|
|
150
|
+
*
|
|
151
|
+
* Note: This is similar to `fstatat` in POSIX, except that it does not
|
|
152
|
+
* return device and inode information. See the `stat` description for a
|
|
153
|
+
* discussion of alternatives.
|
|
154
|
+
*
|
|
155
|
+
* Note: This was called `path_filestat_get` in earlier versions of WASI.
|
|
156
|
+
*/
|
|
157
|
+
export function statAt(this_: Descriptor, pathFlags: PathFlags, path: string): DescriptorStat;
|
|
158
|
+
/**
|
|
159
|
+
* Adjust the timestamps of a file or directory.
|
|
160
|
+
*
|
|
161
|
+
* Note: This is similar to `utimensat` in POSIX.
|
|
162
|
+
*
|
|
163
|
+
* Note: This was called `path_filestat_set_times` in earlier versions of
|
|
164
|
+
* WASI.
|
|
165
|
+
*/
|
|
166
|
+
export function setTimesAt(this_: Descriptor, pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
|
|
167
|
+
/**
|
|
168
|
+
* Create a hard link.
|
|
169
|
+
*
|
|
170
|
+
* Note: This is similar to `linkat` in POSIX.
|
|
171
|
+
*/
|
|
172
|
+
export function linkAt(this_: Descriptor, oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
|
|
173
|
+
/**
|
|
174
|
+
* Open a file or directory.
|
|
175
|
+
*
|
|
176
|
+
* The returned descriptor is not guaranteed to be the lowest-numbered
|
|
177
|
+
* descriptor not currently open/ it is randomized to prevent applications
|
|
178
|
+
* from depending on making assumptions about indexes, since this is
|
|
179
|
+
* error-prone in multi-threaded contexts. The returned descriptor is
|
|
180
|
+
* guaranteed to be less than 2**31.
|
|
181
|
+
*
|
|
182
|
+
* If `flags` contains `descriptor-flags::mutate-directory`, and the base
|
|
183
|
+
* descriptor doesn't have `descriptor-flags::mutate-directory` set,
|
|
184
|
+
* `open-at` fails with `error-code::read-only`.
|
|
185
|
+
*
|
|
186
|
+
* If `flags` contains `write` or `mutate-directory`, or `open-flags`
|
|
187
|
+
* contains `truncate` or `create`, and the base descriptor doesn't have
|
|
188
|
+
* `descriptor-flags::mutate-directory` set, `open-at` fails with
|
|
189
|
+
* `error-code::read-only`.
|
|
190
|
+
*
|
|
191
|
+
* Note: This is similar to `openat` in POSIX.
|
|
192
|
+
*/
|
|
193
|
+
export function openAt(this_: Descriptor, pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags, modes: Modes): Descriptor;
|
|
194
|
+
/**
|
|
195
|
+
* Read the contents of a symbolic link.
|
|
196
|
+
*
|
|
197
|
+
* If the contents contain an absolute or rooted path in the underlying
|
|
198
|
+
* filesystem, this function fails with `error-code::not-permitted`.
|
|
199
|
+
*
|
|
200
|
+
* Note: This is similar to `readlinkat` in POSIX.
|
|
201
|
+
*/
|
|
202
|
+
export function readlinkAt(this_: Descriptor, path: string): string;
|
|
203
|
+
/**
|
|
204
|
+
* Remove a directory.
|
|
205
|
+
*
|
|
206
|
+
* Return `error-code::not-empty` if the directory is not empty.
|
|
207
|
+
*
|
|
208
|
+
* Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
|
|
209
|
+
*/
|
|
210
|
+
export function removeDirectoryAt(this_: Descriptor, path: string): void;
|
|
211
|
+
/**
|
|
212
|
+
* Rename a filesystem object.
|
|
213
|
+
*
|
|
214
|
+
* Note: This is similar to `renameat` in POSIX.
|
|
215
|
+
*/
|
|
216
|
+
export function renameAt(this_: Descriptor, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
|
|
217
|
+
/**
|
|
218
|
+
* Create a symbolic link (also known as a "symlink").
|
|
219
|
+
*
|
|
220
|
+
* If `old-path` starts with `/`, the function fails with
|
|
221
|
+
* `error-code::not-permitted`.
|
|
222
|
+
*
|
|
223
|
+
* Note: This is similar to `symlinkat` in POSIX.
|
|
224
|
+
*/
|
|
225
|
+
export function symlinkAt(this_: Descriptor, oldPath: string, newPath: string): void;
|
|
226
|
+
/**
|
|
227
|
+
* Check accessibility of a filesystem path.
|
|
228
|
+
*
|
|
229
|
+
* Check whether the given filesystem path names an object which is
|
|
230
|
+
* readable, writable, or executable, or whether it exists.
|
|
231
|
+
*
|
|
232
|
+
* This does not a guarantee that subsequent accesses will succeed, as
|
|
233
|
+
* filesystem permissions may be modified asynchronously by external
|
|
234
|
+
* entities.
|
|
235
|
+
*
|
|
236
|
+
* Note: This is similar to `faccessat` with the `AT_EACCESS` flag in POSIX.
|
|
237
|
+
*/
|
|
238
|
+
export function accessAt(this_: Descriptor, pathFlags: PathFlags, path: string, type: AccessType): void;
|
|
239
|
+
/**
|
|
240
|
+
* Unlink a filesystem object that is not a directory.
|
|
241
|
+
*
|
|
242
|
+
* Return `error-code::is-directory` if the path refers to a directory.
|
|
243
|
+
* Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
|
|
244
|
+
*/
|
|
245
|
+
export function unlinkFileAt(this_: Descriptor, path: string): void;
|
|
246
|
+
/**
|
|
247
|
+
* Change the permissions of a filesystem object that is not a directory.
|
|
248
|
+
*
|
|
249
|
+
* Note that the ultimate meanings of these permissions is
|
|
250
|
+
* filesystem-specific.
|
|
251
|
+
*
|
|
252
|
+
* Note: This is similar to `fchmodat` in POSIX.
|
|
253
|
+
*/
|
|
254
|
+
export function changeFilePermissionsAt(this_: Descriptor, pathFlags: PathFlags, path: string, modes: Modes): void;
|
|
255
|
+
/**
|
|
256
|
+
* Change the permissions of a directory.
|
|
257
|
+
*
|
|
258
|
+
* Note that the ultimate meanings of these permissions is
|
|
259
|
+
* filesystem-specific.
|
|
260
|
+
*
|
|
261
|
+
* Unlike in POSIX, the `executable` flag is not reinterpreted as a "search"
|
|
262
|
+
* flag. `read` on a directory implies readability and searchability, and
|
|
263
|
+
* `execute` is not valid for directories.
|
|
264
|
+
*
|
|
265
|
+
* Note: This is similar to `fchmodat` in POSIX.
|
|
266
|
+
*/
|
|
267
|
+
export function changeDirectoryPermissionsAt(this_: Descriptor, pathFlags: PathFlags, path: string, modes: Modes): void;
|
|
268
|
+
/**
|
|
269
|
+
* Request a shared advisory lock for an open file.
|
|
270
|
+
*
|
|
271
|
+
* This requests a *shared* lock; more than one shared lock can be held for
|
|
272
|
+
* a file at the same time.
|
|
273
|
+
*
|
|
274
|
+
* If the open file has an exclusive lock, this function downgrades the lock
|
|
275
|
+
* to a shared lock. If it has a shared lock, this function has no effect.
|
|
276
|
+
*
|
|
277
|
+
* This requests an *advisory* lock, meaning that the file could be accessed
|
|
278
|
+
* by other programs that don't hold the lock.
|
|
279
|
+
*
|
|
280
|
+
* It is unspecified how shared locks interact with locks acquired by
|
|
281
|
+
* non-WASI programs.
|
|
282
|
+
*
|
|
283
|
+
* This function blocks until the lock can be acquired.
|
|
284
|
+
*
|
|
285
|
+
* Not all filesystems support locking; on filesystems which don't support
|
|
286
|
+
* locking, this function returns `error-code::unsupported`.
|
|
287
|
+
*
|
|
288
|
+
* Note: This is similar to `flock(fd, LOCK_SH)` in Unix.
|
|
289
|
+
*/
|
|
290
|
+
export function lockShared(this_: Descriptor): void;
|
|
291
|
+
/**
|
|
292
|
+
* Request an exclusive advisory lock for an open file.
|
|
293
|
+
*
|
|
294
|
+
* This requests an *exclusive* lock; no other locks may be held for the
|
|
295
|
+
* file while an exclusive lock is held.
|
|
296
|
+
*
|
|
297
|
+
* If the open file has a shared lock and there are no exclusive locks held
|
|
298
|
+
* for the file, this function upgrades the lock to an exclusive lock. If the
|
|
299
|
+
* open file already has an exclusive lock, this function has no effect.
|
|
300
|
+
*
|
|
301
|
+
* This requests an *advisory* lock, meaning that the file could be accessed
|
|
302
|
+
* by other programs that don't hold the lock.
|
|
303
|
+
*
|
|
304
|
+
* It is unspecified whether this function succeeds if the file descriptor
|
|
305
|
+
* is not opened for writing. It is unspecified how exclusive locks interact
|
|
306
|
+
* with locks acquired by non-WASI programs.
|
|
307
|
+
*
|
|
308
|
+
* This function blocks until the lock can be acquired.
|
|
309
|
+
*
|
|
310
|
+
* Not all filesystems support locking; on filesystems which don't support
|
|
311
|
+
* locking, this function returns `error-code::unsupported`.
|
|
312
|
+
*
|
|
313
|
+
* Note: This is similar to `flock(fd, LOCK_EX)` in Unix.
|
|
314
|
+
*/
|
|
315
|
+
export function lockExclusive(this_: Descriptor): void;
|
|
316
|
+
/**
|
|
317
|
+
* Request a shared advisory lock for an open file.
|
|
318
|
+
*
|
|
319
|
+
* This requests a *shared* lock; more than one shared lock can be held for
|
|
320
|
+
* a file at the same time.
|
|
321
|
+
*
|
|
322
|
+
* If the open file has an exclusive lock, this function downgrades the lock
|
|
323
|
+
* to a shared lock. If it has a shared lock, this function has no effect.
|
|
324
|
+
*
|
|
325
|
+
* This requests an *advisory* lock, meaning that the file could be accessed
|
|
326
|
+
* by other programs that don't hold the lock.
|
|
327
|
+
*
|
|
328
|
+
* It is unspecified how shared locks interact with locks acquired by
|
|
329
|
+
* non-WASI programs.
|
|
330
|
+
*
|
|
331
|
+
* This function returns `error-code::would-block` if the lock cannot be
|
|
332
|
+
* acquired.
|
|
333
|
+
*
|
|
334
|
+
* Not all filesystems support locking; on filesystems which don't support
|
|
335
|
+
* locking, this function returns `error-code::unsupported`.
|
|
336
|
+
*
|
|
337
|
+
* Note: This is similar to `flock(fd, LOCK_SH | LOCK_NB)` in Unix.
|
|
338
|
+
*/
|
|
339
|
+
export function tryLockShared(this_: Descriptor): void;
|
|
340
|
+
/**
|
|
341
|
+
* Request an exclusive advisory lock for an open file.
|
|
342
|
+
*
|
|
343
|
+
* This requests an *exclusive* lock; no other locks may be held for the
|
|
344
|
+
* file while an exclusive lock is held.
|
|
345
|
+
*
|
|
346
|
+
* If the open file has a shared lock and there are no exclusive locks held
|
|
347
|
+
* for the file, this function upgrades the lock to an exclusive lock. If the
|
|
348
|
+
* open file already has an exclusive lock, this function has no effect.
|
|
349
|
+
*
|
|
350
|
+
* This requests an *advisory* lock, meaning that the file could be accessed
|
|
351
|
+
* by other programs that don't hold the lock.
|
|
352
|
+
*
|
|
353
|
+
* It is unspecified whether this function succeeds if the file descriptor
|
|
354
|
+
* is not opened for writing. It is unspecified how exclusive locks interact
|
|
355
|
+
* with locks acquired by non-WASI programs.
|
|
356
|
+
*
|
|
357
|
+
* This function returns `error-code::would-block` if the lock cannot be
|
|
358
|
+
* acquired.
|
|
359
|
+
*
|
|
360
|
+
* Not all filesystems support locking; on filesystems which don't support
|
|
361
|
+
* locking, this function returns `error-code::unsupported`.
|
|
362
|
+
*
|
|
363
|
+
* Note: This is similar to `flock(fd, LOCK_EX | LOCK_NB)` in Unix.
|
|
364
|
+
*/
|
|
365
|
+
export function tryLockExclusive(this_: Descriptor): void;
|
|
366
|
+
/**
|
|
367
|
+
* Release a shared or exclusive lock on an open file.
|
|
368
|
+
*
|
|
369
|
+
* Note: This is similar to `flock(fd, LOCK_UN)` in Unix.
|
|
370
|
+
*/
|
|
371
|
+
export function unlock(this_: Descriptor): void;
|
|
372
|
+
/**
|
|
373
|
+
* Dispose of the specified `descriptor`, after which it may no longer
|
|
374
|
+
* be used.
|
|
375
|
+
*/
|
|
376
|
+
export function dropDescriptor(this_: Descriptor): void;
|
|
377
|
+
/**
|
|
378
|
+
* Read a single directory entry from a `directory-entry-stream`.
|
|
379
|
+
*/
|
|
380
|
+
export function readDirectoryEntry(this_: DirectoryEntryStream): DirectoryEntry | null;
|
|
381
|
+
/**
|
|
382
|
+
* Dispose of the specified `directory-entry-stream`, after which it may no longer
|
|
383
|
+
* be used.
|
|
384
|
+
*/
|
|
385
|
+
export function dropDirectoryEntryStream(this_: DirectoryEntryStream): void;
|
|
386
|
+
/**
|
|
387
|
+
* Test whether two descriptors refer to the same filesystem object.
|
|
388
|
+
*
|
|
389
|
+
* In POSIX, this corresponds to testing whether the two descriptors have the
|
|
390
|
+
* same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
|
|
391
|
+
* wasi-filesystem does not expose device and inode numbers, so this function
|
|
392
|
+
* may be used instead.
|
|
393
|
+
*/
|
|
394
|
+
export function isSameObject(this_: Descriptor, other: Descriptor): boolean;
|
|
395
|
+
/**
|
|
396
|
+
* Return a hash of the metadata associated with a filesystem object referred
|
|
397
|
+
* to by a descriptor.
|
|
398
|
+
*
|
|
399
|
+
* This returns a hash of the last-modification timestamp and file size, and
|
|
400
|
+
* may also include the inode number, device number, birth timestamp, and
|
|
401
|
+
* other metadata fields that may change when the file is modified or
|
|
402
|
+
* replaced. It may also include a secret value chosen by the
|
|
403
|
+
* implementation and not otherwise exposed.
|
|
404
|
+
*
|
|
405
|
+
* Implementations are encourated to provide the following properties:
|
|
406
|
+
*
|
|
407
|
+
* - If the file is not modified or replaced, the computed hash value should
|
|
408
|
+
* usually not change.
|
|
409
|
+
* - If the object is modified or replaced, the computed hash value should
|
|
410
|
+
* usually change.
|
|
411
|
+
* - The inputs to the hash should not be easily computable from the
|
|
412
|
+
* computed hash.
|
|
413
|
+
*
|
|
414
|
+
* However, none of these is required.
|
|
415
|
+
*/
|
|
416
|
+
export function metadataHash(this_: Descriptor): MetadataHashValue;
|
|
417
|
+
/**
|
|
418
|
+
* Return a hash of the metadata associated with a filesystem object referred
|
|
419
|
+
* to by a directory descriptor and a relative path.
|
|
420
|
+
*
|
|
421
|
+
* This performs the same hash computation as `metadata-hash`.
|
|
422
|
+
*/
|
|
423
|
+
export function metadataHashAt(this_: Descriptor, pathFlags: PathFlags, path: string): MetadataHashValue;
|
|
424
|
+
}
|
|
425
|
+
import type { InputStream } from '../exports/wasi-io-streams';
|
|
426
|
+
export { InputStream };
|
|
427
|
+
import type { OutputStream } from '../exports/wasi-io-streams';
|
|
428
|
+
export { OutputStream };
|
|
429
|
+
import type { Datetime } from '../exports/wasi-clocks-wall-clock';
|
|
430
|
+
export { Datetime };
|
|
431
|
+
/**
|
|
432
|
+
* File size or length of a region within a file.
|
|
433
|
+
*/
|
|
434
|
+
export type Filesize = bigint;
|
|
435
|
+
/**
|
|
436
|
+
* The type of a filesystem object referenced by a descriptor.
|
|
437
|
+
*
|
|
438
|
+
* Note: This was called `filetype` in earlier versions of WASI.
|
|
439
|
+
* # Variants
|
|
440
|
+
*
|
|
441
|
+
* ## `"unknown"`
|
|
442
|
+
*
|
|
443
|
+
* The type of the descriptor or file is unknown or is different from
|
|
444
|
+
* any of the other types specified.
|
|
445
|
+
* ## `"block-device"`
|
|
446
|
+
*
|
|
447
|
+
* The descriptor refers to a block device inode.
|
|
448
|
+
* ## `"character-device"`
|
|
449
|
+
*
|
|
450
|
+
* The descriptor refers to a character device inode.
|
|
451
|
+
* ## `"directory"`
|
|
452
|
+
*
|
|
453
|
+
* The descriptor refers to a directory inode.
|
|
454
|
+
* ## `"fifo"`
|
|
455
|
+
*
|
|
456
|
+
* The descriptor refers to a named pipe.
|
|
457
|
+
* ## `"symbolic-link"`
|
|
458
|
+
*
|
|
459
|
+
* The file refers to a symbolic link inode.
|
|
460
|
+
* ## `"regular-file"`
|
|
461
|
+
*
|
|
462
|
+
* The descriptor refers to a regular file inode.
|
|
463
|
+
* ## `"socket"`
|
|
464
|
+
*
|
|
465
|
+
* The descriptor refers to a socket.
|
|
466
|
+
*/
|
|
467
|
+
export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
|
|
468
|
+
/**
|
|
469
|
+
* Descriptor flags.
|
|
470
|
+
*
|
|
471
|
+
* Note: This was called `fdflags` in earlier versions of WASI.
|
|
472
|
+
*/
|
|
473
|
+
export interface DescriptorFlags {
|
|
474
|
+
/**
|
|
475
|
+
* Read mode: Data can be read.
|
|
476
|
+
*/
|
|
477
|
+
read?: boolean,
|
|
478
|
+
/**
|
|
479
|
+
* Write mode: Data can be written to.
|
|
480
|
+
*/
|
|
481
|
+
write?: boolean,
|
|
482
|
+
/**
|
|
483
|
+
* Request that writes be performed according to synchronized I/O file
|
|
484
|
+
* integrity completion. The data stored in the file and the file's
|
|
485
|
+
* metadata are synchronized. This is similar to `O_SYNC` in POSIX.
|
|
486
|
+
*
|
|
487
|
+
* The precise semantics of this operation have not yet been defined for
|
|
488
|
+
* WASI. At this time, it should be interpreted as a request, and not a
|
|
489
|
+
* requirement.
|
|
490
|
+
*/
|
|
491
|
+
fileIntegritySync?: boolean,
|
|
492
|
+
/**
|
|
493
|
+
* Request that writes be performed according to synchronized I/O data
|
|
494
|
+
* integrity completion. Only the data stored in the file is
|
|
495
|
+
* synchronized. This is similar to `O_DSYNC` in POSIX.
|
|
496
|
+
*
|
|
497
|
+
* The precise semantics of this operation have not yet been defined for
|
|
498
|
+
* WASI. At this time, it should be interpreted as a request, and not a
|
|
499
|
+
* requirement.
|
|
500
|
+
*/
|
|
501
|
+
dataIntegritySync?: boolean,
|
|
502
|
+
/**
|
|
503
|
+
* Requests that reads be performed at the same level of integrety
|
|
504
|
+
* requested for writes. This is similar to `O_RSYNC` in POSIX.
|
|
505
|
+
*
|
|
506
|
+
* The precise semantics of this operation have not yet been defined for
|
|
507
|
+
* WASI. At this time, it should be interpreted as a request, and not a
|
|
508
|
+
* requirement.
|
|
509
|
+
*/
|
|
510
|
+
requestedWriteSync?: boolean,
|
|
511
|
+
/**
|
|
512
|
+
* Mutating directories mode: Directory contents may be mutated.
|
|
513
|
+
*
|
|
514
|
+
* When this flag is unset on a descriptor, operations using the
|
|
515
|
+
* descriptor which would create, rename, delete, modify the data or
|
|
516
|
+
* metadata of filesystem objects, or obtain another handle which
|
|
517
|
+
* would permit any of those, shall fail with `error-code::read-only` if
|
|
518
|
+
* they would otherwise succeed.
|
|
519
|
+
*
|
|
520
|
+
* This may only be set on directories.
|
|
521
|
+
*/
|
|
522
|
+
mutateDirectory?: boolean,
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Flags determining the method of how paths are resolved.
|
|
526
|
+
*/
|
|
527
|
+
export interface PathFlags {
|
|
528
|
+
/**
|
|
529
|
+
* As long as the resolved path corresponds to a symbolic link, it is
|
|
530
|
+
* expanded.
|
|
531
|
+
*/
|
|
532
|
+
symlinkFollow?: boolean,
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Open flags used by `open-at`.
|
|
536
|
+
*/
|
|
537
|
+
export interface OpenFlags {
|
|
538
|
+
/**
|
|
539
|
+
* Create file if it does not exist, similar to `O_CREAT` in POSIX.
|
|
540
|
+
*/
|
|
541
|
+
create?: boolean,
|
|
542
|
+
/**
|
|
543
|
+
* Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
|
|
544
|
+
*/
|
|
545
|
+
directory?: boolean,
|
|
546
|
+
/**
|
|
547
|
+
* Fail if file already exists, similar to `O_EXCL` in POSIX.
|
|
548
|
+
*/
|
|
549
|
+
exclusive?: boolean,
|
|
550
|
+
/**
|
|
551
|
+
* Truncate file to size 0, similar to `O_TRUNC` in POSIX.
|
|
552
|
+
*/
|
|
553
|
+
truncate?: boolean,
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Permissions mode used by `open-at`, `change-file-permissions-at`, and
|
|
557
|
+
* similar.
|
|
558
|
+
*/
|
|
559
|
+
export interface Modes {
|
|
560
|
+
/**
|
|
561
|
+
* True if the resource is considered readable by the containing
|
|
562
|
+
* filesystem.
|
|
563
|
+
*/
|
|
564
|
+
readable?: boolean,
|
|
565
|
+
/**
|
|
566
|
+
* True if the resource is considered writable by the containing
|
|
567
|
+
* filesystem.
|
|
568
|
+
*/
|
|
569
|
+
writable?: boolean,
|
|
570
|
+
/**
|
|
571
|
+
* True if the resource is considered executable by the containing
|
|
572
|
+
* filesystem. This does not apply to directories.
|
|
573
|
+
*/
|
|
574
|
+
executable?: boolean,
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Access type used by `access-at`.
|
|
578
|
+
*/
|
|
579
|
+
export type AccessType = AccessTypeAccess | AccessTypeExists;
|
|
580
|
+
/**
|
|
581
|
+
* Test for readability, writeability, or executability.
|
|
582
|
+
*/
|
|
583
|
+
export interface AccessTypeAccess {
|
|
584
|
+
tag: 'access',
|
|
585
|
+
val: Modes,
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Test whether the path exists.
|
|
589
|
+
*/
|
|
590
|
+
export interface AccessTypeExists {
|
|
591
|
+
tag: 'exists',
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Number of hard links to an inode.
|
|
595
|
+
*/
|
|
596
|
+
export type LinkCount = bigint;
|
|
597
|
+
/**
|
|
598
|
+
* File attributes.
|
|
599
|
+
*
|
|
600
|
+
* Note: This was called `filestat` in earlier versions of WASI.
|
|
601
|
+
*/
|
|
602
|
+
export interface DescriptorStat {
|
|
603
|
+
/**
|
|
604
|
+
* File type.
|
|
605
|
+
*/
|
|
606
|
+
type: DescriptorType,
|
|
607
|
+
/**
|
|
608
|
+
* Number of hard links to the file.
|
|
609
|
+
*/
|
|
610
|
+
linkCount: LinkCount,
|
|
611
|
+
/**
|
|
612
|
+
* For regular files, the file size in bytes. For symbolic links, the
|
|
613
|
+
* length in bytes of the pathname contained in the symbolic link.
|
|
614
|
+
*/
|
|
615
|
+
size: Filesize,
|
|
616
|
+
/**
|
|
617
|
+
* Last data access timestamp.
|
|
618
|
+
*/
|
|
619
|
+
dataAccessTimestamp: Datetime,
|
|
620
|
+
/**
|
|
621
|
+
* Last data modification timestamp.
|
|
622
|
+
*/
|
|
623
|
+
dataModificationTimestamp: Datetime,
|
|
624
|
+
/**
|
|
625
|
+
* Last file status change timestamp.
|
|
626
|
+
*/
|
|
627
|
+
statusChangeTimestamp: Datetime,
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* When setting a timestamp, this gives the value to set it to.
|
|
631
|
+
*/
|
|
632
|
+
export type NewTimestamp = NewTimestampNoChange | NewTimestampNow | NewTimestampTimestamp;
|
|
633
|
+
/**
|
|
634
|
+
* Leave the timestamp set to its previous value.
|
|
635
|
+
*/
|
|
636
|
+
export interface NewTimestampNoChange {
|
|
637
|
+
tag: 'no-change',
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Set the timestamp to the current time of the system clock associated
|
|
641
|
+
* with the filesystem.
|
|
642
|
+
*/
|
|
643
|
+
export interface NewTimestampNow {
|
|
644
|
+
tag: 'now',
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Set the timestamp to the given value.
|
|
648
|
+
*/
|
|
649
|
+
export interface NewTimestampTimestamp {
|
|
650
|
+
tag: 'timestamp',
|
|
651
|
+
val: Datetime,
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* A directory entry.
|
|
655
|
+
*/
|
|
656
|
+
export interface DirectoryEntry {
|
|
657
|
+
/**
|
|
658
|
+
* The type of the file referred to by this directory entry.
|
|
659
|
+
*/
|
|
660
|
+
type: DescriptorType,
|
|
661
|
+
/**
|
|
662
|
+
* The name of the object.
|
|
663
|
+
*/
|
|
664
|
+
name: string,
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Error codes returned by functions, similar to `errno` in POSIX.
|
|
668
|
+
* Not all of these error codes are returned by the functions provided by this
|
|
669
|
+
* API; some are used in higher-level library layers, and others are provided
|
|
670
|
+
* merely for alignment with POSIX.
|
|
671
|
+
* # Variants
|
|
672
|
+
*
|
|
673
|
+
* ## `"access"`
|
|
674
|
+
*
|
|
675
|
+
* Permission denied, similar to `EACCES` in POSIX.
|
|
676
|
+
* ## `"would-block"`
|
|
677
|
+
*
|
|
678
|
+
* Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
|
|
679
|
+
* ## `"already"`
|
|
680
|
+
*
|
|
681
|
+
* Connection already in progress, similar to `EALREADY` in POSIX.
|
|
682
|
+
* ## `"bad-descriptor"`
|
|
683
|
+
*
|
|
684
|
+
* Bad descriptor, similar to `EBADF` in POSIX.
|
|
685
|
+
* ## `"busy"`
|
|
686
|
+
*
|
|
687
|
+
* Device or resource busy, similar to `EBUSY` in POSIX.
|
|
688
|
+
* ## `"deadlock"`
|
|
689
|
+
*
|
|
690
|
+
* Resource deadlock would occur, similar to `EDEADLK` in POSIX.
|
|
691
|
+
* ## `"quota"`
|
|
692
|
+
*
|
|
693
|
+
* Storage quota exceeded, similar to `EDQUOT` in POSIX.
|
|
694
|
+
* ## `"exist"`
|
|
695
|
+
*
|
|
696
|
+
* File exists, similar to `EEXIST` in POSIX.
|
|
697
|
+
* ## `"file-too-large"`
|
|
698
|
+
*
|
|
699
|
+
* File too large, similar to `EFBIG` in POSIX.
|
|
700
|
+
* ## `"illegal-byte-sequence"`
|
|
701
|
+
*
|
|
702
|
+
* Illegal byte sequence, similar to `EILSEQ` in POSIX.
|
|
703
|
+
* ## `"in-progress"`
|
|
704
|
+
*
|
|
705
|
+
* Operation in progress, similar to `EINPROGRESS` in POSIX.
|
|
706
|
+
* ## `"interrupted"`
|
|
707
|
+
*
|
|
708
|
+
* Interrupted function, similar to `EINTR` in POSIX.
|
|
709
|
+
* ## `"invalid"`
|
|
710
|
+
*
|
|
711
|
+
* Invalid argument, similar to `EINVAL` in POSIX.
|
|
712
|
+
* ## `"io"`
|
|
713
|
+
*
|
|
714
|
+
* I/O error, similar to `EIO` in POSIX.
|
|
715
|
+
* ## `"is-directory"`
|
|
716
|
+
*
|
|
717
|
+
* Is a directory, similar to `EISDIR` in POSIX.
|
|
718
|
+
* ## `"loop"`
|
|
719
|
+
*
|
|
720
|
+
* Too many levels of symbolic links, similar to `ELOOP` in POSIX.
|
|
721
|
+
* ## `"too-many-links"`
|
|
722
|
+
*
|
|
723
|
+
* Too many links, similar to `EMLINK` in POSIX.
|
|
724
|
+
* ## `"message-size"`
|
|
725
|
+
*
|
|
726
|
+
* Message too large, similar to `EMSGSIZE` in POSIX.
|
|
727
|
+
* ## `"name-too-long"`
|
|
728
|
+
*
|
|
729
|
+
* Filename too long, similar to `ENAMETOOLONG` in POSIX.
|
|
730
|
+
* ## `"no-device"`
|
|
731
|
+
*
|
|
732
|
+
* No such device, similar to `ENODEV` in POSIX.
|
|
733
|
+
* ## `"no-entry"`
|
|
734
|
+
*
|
|
735
|
+
* No such file or directory, similar to `ENOENT` in POSIX.
|
|
736
|
+
* ## `"no-lock"`
|
|
737
|
+
*
|
|
738
|
+
* No locks available, similar to `ENOLCK` in POSIX.
|
|
739
|
+
* ## `"insufficient-memory"`
|
|
740
|
+
*
|
|
741
|
+
* Not enough space, similar to `ENOMEM` in POSIX.
|
|
742
|
+
* ## `"insufficient-space"`
|
|
743
|
+
*
|
|
744
|
+
* No space left on device, similar to `ENOSPC` in POSIX.
|
|
745
|
+
* ## `"not-directory"`
|
|
746
|
+
*
|
|
747
|
+
* Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
|
|
748
|
+
* ## `"not-empty"`
|
|
749
|
+
*
|
|
750
|
+
* Directory not empty, similar to `ENOTEMPTY` in POSIX.
|
|
751
|
+
* ## `"not-recoverable"`
|
|
752
|
+
*
|
|
753
|
+
* State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
|
|
754
|
+
* ## `"unsupported"`
|
|
755
|
+
*
|
|
756
|
+
* Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
|
|
757
|
+
* ## `"no-tty"`
|
|
758
|
+
*
|
|
759
|
+
* Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
|
|
760
|
+
* ## `"no-such-device"`
|
|
761
|
+
*
|
|
762
|
+
* No such device or address, similar to `ENXIO` in POSIX.
|
|
763
|
+
* ## `"overflow"`
|
|
764
|
+
*
|
|
765
|
+
* Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
|
|
766
|
+
* ## `"not-permitted"`
|
|
767
|
+
*
|
|
768
|
+
* Operation not permitted, similar to `EPERM` in POSIX.
|
|
769
|
+
* ## `"pipe"`
|
|
770
|
+
*
|
|
771
|
+
* Broken pipe, similar to `EPIPE` in POSIX.
|
|
772
|
+
* ## `"read-only"`
|
|
773
|
+
*
|
|
774
|
+
* Read-only file system, similar to `EROFS` in POSIX.
|
|
775
|
+
* ## `"invalid-seek"`
|
|
776
|
+
*
|
|
777
|
+
* Invalid seek, similar to `ESPIPE` in POSIX.
|
|
778
|
+
* ## `"text-file-busy"`
|
|
779
|
+
*
|
|
780
|
+
* Text file busy, similar to `ETXTBSY` in POSIX.
|
|
781
|
+
* ## `"cross-device"`
|
|
782
|
+
*
|
|
783
|
+
* Cross-device link, similar to `EXDEV` in POSIX.
|
|
784
|
+
*/
|
|
785
|
+
export type ErrorCode = 'access' | 'would-block' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
|
|
786
|
+
/**
|
|
787
|
+
* File or memory access pattern advisory information.
|
|
788
|
+
* # Variants
|
|
789
|
+
*
|
|
790
|
+
* ## `"normal"`
|
|
791
|
+
*
|
|
792
|
+
* The application has no advice to give on its behavior with respect
|
|
793
|
+
* to the specified data.
|
|
794
|
+
* ## `"sequential"`
|
|
795
|
+
*
|
|
796
|
+
* The application expects to access the specified data sequentially
|
|
797
|
+
* from lower offsets to higher offsets.
|
|
798
|
+
* ## `"random"`
|
|
799
|
+
*
|
|
800
|
+
* The application expects to access the specified data in a random
|
|
801
|
+
* order.
|
|
802
|
+
* ## `"will-need"`
|
|
803
|
+
*
|
|
804
|
+
* The application expects to access the specified data in the near
|
|
805
|
+
* future.
|
|
806
|
+
* ## `"dont-need"`
|
|
807
|
+
*
|
|
808
|
+
* The application expects that it will not access the specified data
|
|
809
|
+
* in the near future.
|
|
810
|
+
* ## `"no-reuse"`
|
|
811
|
+
*
|
|
812
|
+
* The application expects to access the specified data once and then
|
|
813
|
+
* not reuse it thereafter.
|
|
814
|
+
*/
|
|
815
|
+
export type Advice = 'normal' | 'sequential' | 'random' | 'will-need' | 'dont-need' | 'no-reuse';
|
|
816
|
+
/**
|
|
817
|
+
* A descriptor is a reference to a filesystem object, which may be a file,
|
|
818
|
+
* directory, named pipe, special file, or other object on which filesystem
|
|
819
|
+
* calls may be made.
|
|
820
|
+
*
|
|
821
|
+
* This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
|
|
822
|
+
*/
|
|
823
|
+
export type Descriptor = number;
|
|
824
|
+
/**
|
|
825
|
+
* A 128-bit hash value, split into parts because wasm doesn't have a
|
|
826
|
+
* 128-bit integer type.
|
|
827
|
+
*/
|
|
828
|
+
export interface MetadataHashValue {
|
|
829
|
+
/**
|
|
830
|
+
* 64 bits of a 128-bit hash value.
|
|
831
|
+
*/
|
|
832
|
+
lower: bigint,
|
|
833
|
+
/**
|
|
834
|
+
* Another 64 bits of a 128-bit hash value.
|
|
835
|
+
*/
|
|
836
|
+
upper: bigint,
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* A stream of directory entries.
|
|
840
|
+
*
|
|
841
|
+
* This [represents a stream of `dir-entry`](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Streams).
|
|
842
|
+
*/
|
|
843
|
+
export type DirectoryEntryStream = number;
|