wasmkeep 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,589 @@
1
+ package wasi:filesystem@0.2.12;
2
+
3
+ /// WASI filesystem is a filesystem API primarily intended to let users run WASI
4
+ /// programs that access their files on their existing filesystems, without
5
+ /// significant overhead.
6
+ ///
7
+ /// It is intended to be roughly portable between Unix-family platforms and
8
+ /// Windows, though it does not hide many of the major differences.
9
+ ///
10
+ /// Paths are passed as interface-type `string`s, meaning they must consist of
11
+ /// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain
12
+ /// paths which are not accessible by this API.
13
+ ///
14
+ /// The directory separator in WASI is always the forward-slash (`/`).
15
+ ///
16
+ /// All paths in WASI are relative paths, and are interpreted relative to a
17
+ /// `descriptor` referring to a base directory. If a `path` argument to any WASI
18
+ /// function starts with `/`, or if any step of resolving a `path`, including
19
+ /// `..` and symbolic link steps, reaches a directory outside of the base
20
+ /// directory, or reaches a symlink to an absolute or rooted path in the
21
+ /// underlying filesystem, the function fails with `error-code::not-permitted`.
22
+ ///
23
+ /// For more information about WASI path resolution and sandboxing, see
24
+ /// [WASI filesystem path resolution].
25
+ ///
26
+ /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md
27
+ @since(version = 0.2.0)
28
+ interface types {
29
+ @since(version = 0.2.0)
30
+ use wasi:io/streams@0.2.12.{input-stream, output-stream, error};
31
+ @since(version = 0.2.0)
32
+ use wasi:clocks/wall-clock@0.2.12.{datetime};
33
+
34
+ /// File size or length of a region within a file.
35
+ @since(version = 0.2.0)
36
+ type filesize = u64;
37
+
38
+ /// The type of a filesystem object referenced by a descriptor.
39
+ ///
40
+ /// Note: This was called `filetype` in earlier versions of WASI.
41
+ @since(version = 0.2.0)
42
+ enum descriptor-type {
43
+ /// The type of the descriptor or file is unknown or is different from
44
+ /// any of the other types specified.
45
+ unknown,
46
+ /// The descriptor refers to a block device inode.
47
+ block-device,
48
+ /// The descriptor refers to a character device inode.
49
+ character-device,
50
+ /// The descriptor refers to a directory inode.
51
+ directory,
52
+ /// The descriptor refers to a named pipe.
53
+ fifo,
54
+ /// The file refers to a symbolic link inode.
55
+ symbolic-link,
56
+ /// The descriptor refers to a regular file inode.
57
+ regular-file,
58
+ /// The descriptor refers to a socket.
59
+ socket,
60
+ }
61
+
62
+ /// Descriptor flags.
63
+ ///
64
+ /// Note: This was called `fdflags` in earlier versions of WASI.
65
+ @since(version = 0.2.0)
66
+ flags descriptor-flags {
67
+ /// Read mode: Data can be read.
68
+ read,
69
+ /// Write mode: Data can be written to.
70
+ write,
71
+ /// Request that writes be performed according to synchronized I/O file
72
+ /// integrity completion. The data stored in the file and the file's
73
+ /// metadata are synchronized. This is similar to `O_SYNC` in POSIX.
74
+ ///
75
+ /// The precise semantics of this operation have not yet been defined for
76
+ /// WASI. At this time, it should be interpreted as a request, and not a
77
+ /// requirement.
78
+ file-integrity-sync,
79
+ /// Request that writes be performed according to synchronized I/O data
80
+ /// integrity completion. Only the data stored in the file is
81
+ /// synchronized. This is similar to `O_DSYNC` in POSIX.
82
+ ///
83
+ /// The precise semantics of this operation have not yet been defined for
84
+ /// WASI. At this time, it should be interpreted as a request, and not a
85
+ /// requirement.
86
+ data-integrity-sync,
87
+ /// Requests that reads be performed at the same level of integrity
88
+ /// requested for writes. This is similar to `O_RSYNC` in POSIX.
89
+ ///
90
+ /// The precise semantics of this operation have not yet been defined for
91
+ /// WASI. At this time, it should be interpreted as a request, and not a
92
+ /// requirement.
93
+ requested-write-sync,
94
+ /// Mutating directories mode: Directory contents may be mutated.
95
+ ///
96
+ /// When this flag is unset on a descriptor, operations using the
97
+ /// descriptor which would create, rename, delete, modify the data or
98
+ /// metadata of filesystem objects, or obtain another handle which
99
+ /// would permit any of those, shall fail with `error-code::read-only` if
100
+ /// they would otherwise succeed.
101
+ ///
102
+ /// This may only be set on directories.
103
+ mutate-directory,
104
+ }
105
+
106
+ /// Flags determining the method of how paths are resolved.
107
+ @since(version = 0.2.0)
108
+ flags path-flags {
109
+ /// As long as the resolved path corresponds to a symbolic link, it is
110
+ /// expanded.
111
+ symlink-follow,
112
+ }
113
+
114
+ /// Open flags used by `open-at`.
115
+ @since(version = 0.2.0)
116
+ flags open-flags {
117
+ /// Create file if it does not exist, similar to `O_CREAT` in POSIX.
118
+ create,
119
+ /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
120
+ directory,
121
+ /// Fail if file already exists, similar to `O_EXCL` in POSIX.
122
+ exclusive,
123
+ /// Truncate file to size 0, similar to `O_TRUNC` in POSIX.
124
+ truncate,
125
+ }
126
+
127
+ /// Number of hard links to an inode.
128
+ @since(version = 0.2.0)
129
+ type link-count = u64;
130
+
131
+ /// File attributes.
132
+ ///
133
+ /// Note: This was called `filestat` in earlier versions of WASI.
134
+ @since(version = 0.2.0)
135
+ record descriptor-stat {
136
+ /// File type.
137
+ %type: descriptor-type,
138
+ /// Number of hard links to the file.
139
+ link-count: link-count,
140
+ /// For regular files, the file size in bytes. For symbolic links, the
141
+ /// length in bytes of the pathname contained in the symbolic link.
142
+ size: filesize,
143
+ /// Last data access timestamp.
144
+ ///
145
+ /// If the `option` is none, the platform doesn't maintain an access
146
+ /// timestamp for this file.
147
+ data-access-timestamp: option<datetime>,
148
+ /// Last data modification timestamp.
149
+ ///
150
+ /// If the `option` is none, the platform doesn't maintain a
151
+ /// modification timestamp for this file.
152
+ data-modification-timestamp: option<datetime>,
153
+ /// Last file status-change timestamp.
154
+ ///
155
+ /// If the `option` is none, the platform doesn't maintain a
156
+ /// status-change timestamp for this file.
157
+ status-change-timestamp: option<datetime>,
158
+ }
159
+
160
+ /// When setting a timestamp, this gives the value to set it to.
161
+ @since(version = 0.2.0)
162
+ variant new-timestamp {
163
+ /// Leave the timestamp set to its previous value.
164
+ no-change,
165
+ /// Set the timestamp to the current time of the system clock associated
166
+ /// with the filesystem.
167
+ now,
168
+ /// Set the timestamp to the given value.
169
+ timestamp(datetime),
170
+ }
171
+
172
+ /// A directory entry.
173
+ @since(version = 0.2.0)
174
+ record directory-entry {
175
+ /// The type of the file referred to by this directory entry.
176
+ %type: descriptor-type,
177
+ /// The name of the object.
178
+ name: string,
179
+ }
180
+
181
+ /// Error codes returned by functions, similar to `errno` in POSIX.
182
+ /// Not all of these error codes are returned by the functions provided by this
183
+ /// API; some are used in higher-level library layers, and others are provided
184
+ /// merely for alignment with POSIX.
185
+ @since(version = 0.2.0)
186
+ enum error-code {
187
+ /// Permission denied, similar to `EACCES` in POSIX.
188
+ access,
189
+ /// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
190
+ would-block,
191
+ /// Connection already in progress, similar to `EALREADY` in POSIX.
192
+ already,
193
+ /// Bad descriptor, similar to `EBADF` in POSIX.
194
+ bad-descriptor,
195
+ /// Device or resource busy, similar to `EBUSY` in POSIX.
196
+ busy,
197
+ /// Resource deadlock would occur, similar to `EDEADLK` in POSIX.
198
+ deadlock,
199
+ /// Storage quota exceeded, similar to `EDQUOT` in POSIX.
200
+ quota,
201
+ /// File exists, similar to `EEXIST` in POSIX.
202
+ exist,
203
+ /// File too large, similar to `EFBIG` in POSIX.
204
+ file-too-large,
205
+ /// Illegal byte sequence, similar to `EILSEQ` in POSIX.
206
+ illegal-byte-sequence,
207
+ /// Operation in progress, similar to `EINPROGRESS` in POSIX.
208
+ in-progress,
209
+ /// Interrupted function, similar to `EINTR` in POSIX.
210
+ interrupted,
211
+ /// Invalid argument, similar to `EINVAL` in POSIX.
212
+ invalid,
213
+ /// I/O error, similar to `EIO` in POSIX.
214
+ io,
215
+ /// Is a directory, similar to `EISDIR` in POSIX.
216
+ is-directory,
217
+ /// Too many levels of symbolic links, similar to `ELOOP` in POSIX.
218
+ loop,
219
+ /// Too many links, similar to `EMLINK` in POSIX.
220
+ too-many-links,
221
+ /// Message too large, similar to `EMSGSIZE` in POSIX.
222
+ message-size,
223
+ /// Filename too long, similar to `ENAMETOOLONG` in POSIX.
224
+ name-too-long,
225
+ /// No such device, similar to `ENODEV` in POSIX.
226
+ no-device,
227
+ /// No such file or directory, similar to `ENOENT` in POSIX.
228
+ no-entry,
229
+ /// No locks available, similar to `ENOLCK` in POSIX.
230
+ no-lock,
231
+ /// Not enough space, similar to `ENOMEM` in POSIX.
232
+ insufficient-memory,
233
+ /// No space left on device, similar to `ENOSPC` in POSIX.
234
+ insufficient-space,
235
+ /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
236
+ not-directory,
237
+ /// Directory not empty, similar to `ENOTEMPTY` in POSIX.
238
+ not-empty,
239
+ /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
240
+ not-recoverable,
241
+ /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
242
+ unsupported,
243
+ /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
244
+ no-tty,
245
+ /// No such device or address, similar to `ENXIO` in POSIX.
246
+ no-such-device,
247
+ /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
248
+ overflow,
249
+ /// Operation not permitted, similar to `EPERM` in POSIX.
250
+ not-permitted,
251
+ /// Broken pipe, similar to `EPIPE` in POSIX.
252
+ pipe,
253
+ /// Read-only file system, similar to `EROFS` in POSIX.
254
+ read-only,
255
+ /// Invalid seek, similar to `ESPIPE` in POSIX.
256
+ invalid-seek,
257
+ /// Text file busy, similar to `ETXTBSY` in POSIX.
258
+ text-file-busy,
259
+ /// Cross-device link, similar to `EXDEV` in POSIX.
260
+ cross-device,
261
+ }
262
+
263
+ /// File or memory access pattern advisory information.
264
+ @since(version = 0.2.0)
265
+ enum advice {
266
+ /// The application has no advice to give on its behavior with respect
267
+ /// to the specified data.
268
+ normal,
269
+ /// The application expects to access the specified data sequentially
270
+ /// from lower offsets to higher offsets.
271
+ sequential,
272
+ /// The application expects to access the specified data in a random
273
+ /// order.
274
+ random,
275
+ /// The application expects to access the specified data in the near
276
+ /// future.
277
+ will-need,
278
+ /// The application expects that it will not access the specified data
279
+ /// in the near future.
280
+ dont-need,
281
+ /// The application expects to access the specified data once and then
282
+ /// not reuse it thereafter.
283
+ no-reuse,
284
+ }
285
+
286
+ /// A 128-bit hash value, split into parts because wasm doesn't have a
287
+ /// 128-bit integer type.
288
+ @since(version = 0.2.0)
289
+ record metadata-hash-value {
290
+ /// 64 bits of a 128-bit hash value.
291
+ lower: u64,
292
+ /// Another 64 bits of a 128-bit hash value.
293
+ upper: u64,
294
+ }
295
+
296
+ /// A descriptor is a reference to a filesystem object, which may be a file,
297
+ /// directory, named pipe, special file, or other object on which filesystem
298
+ /// calls may be made.
299
+ @since(version = 0.2.0)
300
+ resource descriptor {
301
+ /// Return a stream for reading from a file, if available.
302
+ ///
303
+ /// May fail with an error-code describing why the file cannot be read.
304
+ ///
305
+ /// Multiple read, write, and append streams may be active on the same open
306
+ /// file and they do not interfere with each other.
307
+ ///
308
+ /// Note: This allows using `read-stream`, which is similar to `read` in POSIX.
309
+ @since(version = 0.2.0)
310
+ read-via-stream: func(offset: filesize) -> result<input-stream, error-code>;
311
+ /// Return a stream for writing to a file, if available.
312
+ ///
313
+ /// May fail with an error-code describing why the file cannot be written.
314
+ ///
315
+ /// Note: This allows using `write-stream`, which is similar to `write` in
316
+ /// POSIX.
317
+ @since(version = 0.2.0)
318
+ write-via-stream: func(offset: filesize) -> result<output-stream, error-code>;
319
+ /// Return a stream for appending to a file, if available.
320
+ ///
321
+ /// May fail with an error-code describing why the file cannot be appended.
322
+ ///
323
+ /// Note: This allows using `write-stream`, which is similar to `write` with
324
+ /// `O_APPEND` in POSIX.
325
+ @since(version = 0.2.0)
326
+ append-via-stream: func() -> result<output-stream, error-code>;
327
+ /// Provide file advisory information on a descriptor.
328
+ ///
329
+ /// This is similar to `posix_fadvise` in POSIX.
330
+ @since(version = 0.2.0)
331
+ advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>;
332
+ /// Synchronize the data of a file to disk.
333
+ ///
334
+ /// This function succeeds with no effect if the file descriptor is not
335
+ /// opened for writing.
336
+ ///
337
+ /// Note: This is similar to `fdatasync` in POSIX.
338
+ @since(version = 0.2.0)
339
+ sync-data: func() -> result<_, error-code>;
340
+ /// Get flags associated with a descriptor.
341
+ ///
342
+ /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.
343
+ ///
344
+ /// Note: This returns the value that was the `fs_flags` value returned
345
+ /// from `fdstat_get` in earlier versions of WASI.
346
+ @since(version = 0.2.0)
347
+ get-flags: func() -> result<descriptor-flags, error-code>;
348
+ /// Get the dynamic type of a descriptor.
349
+ ///
350
+ /// Note: This returns the same value as the `type` field of the `fd-stat`
351
+ /// returned by `stat`, `stat-at` and similar.
352
+ ///
353
+ /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided
354
+ /// by `fstat` in POSIX.
355
+ ///
356
+ /// Note: This returns the value that was the `fs_filetype` value returned
357
+ /// from `fdstat_get` in earlier versions of WASI.
358
+ @since(version = 0.2.0)
359
+ get-type: func() -> result<descriptor-type, error-code>;
360
+ /// Adjust the size of an open file. If this increases the file's size, the
361
+ /// extra bytes are filled with zeros.
362
+ ///
363
+ /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI.
364
+ @since(version = 0.2.0)
365
+ set-size: func(size: filesize) -> result<_, error-code>;
366
+ /// Adjust the timestamps of an open file or directory.
367
+ ///
368
+ /// Note: This is similar to `futimens` in POSIX.
369
+ ///
370
+ /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI.
371
+ @since(version = 0.2.0)
372
+ set-times: func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>;
373
+ /// Read from a descriptor, without using and updating the descriptor's offset.
374
+ ///
375
+ /// This function returns a list of bytes containing the data that was
376
+ /// read, along with a bool which, when true, indicates that the end of the
377
+ /// file was reached. The returned list will contain up to `length` bytes; it
378
+ /// may return fewer than requested, if the end of the file is reached or
379
+ /// if the I/O operation is interrupted.
380
+ ///
381
+ /// In the future, this may change to return a `stream<u8, error-code>`.
382
+ ///
383
+ /// Note: This is similar to `pread` in POSIX.
384
+ @since(version = 0.2.0)
385
+ read: func(length: filesize, offset: filesize) -> result<tuple<list<u8>, bool>, error-code>;
386
+ /// Write to a descriptor, without using and updating the descriptor's offset.
387
+ ///
388
+ /// It is valid to write past the end of a file; the file is extended to the
389
+ /// extent of the write, with bytes between the previous end and the start of
390
+ /// the write set to zero.
391
+ ///
392
+ /// In the future, this may change to take a `stream<u8, error-code>`.
393
+ ///
394
+ /// Note: This is similar to `pwrite` in POSIX.
395
+ @since(version = 0.2.0)
396
+ write: func(buffer: list<u8>, offset: filesize) -> result<filesize, error-code>;
397
+ /// Read directory entries from a directory.
398
+ ///
399
+ /// On filesystems where directories contain entries referring to themselves
400
+ /// and their parents, often named `.` and `..` respectively, these entries
401
+ /// are omitted.
402
+ ///
403
+ /// This always returns a new stream which starts at the beginning of the
404
+ /// directory. Multiple streams may be active on the same directory, and they
405
+ /// do not interfere with each other.
406
+ @since(version = 0.2.0)
407
+ read-directory: func() -> result<directory-entry-stream, error-code>;
408
+ /// Synchronize the data and metadata of a file to disk.
409
+ ///
410
+ /// This function succeeds with no effect if the file descriptor is not
411
+ /// opened for writing.
412
+ ///
413
+ /// Note: This is similar to `fsync` in POSIX.
414
+ @since(version = 0.2.0)
415
+ sync: func() -> result<_, error-code>;
416
+ /// Create a directory.
417
+ ///
418
+ /// Note: This is similar to `mkdirat` in POSIX.
419
+ @since(version = 0.2.0)
420
+ create-directory-at: func(path: string) -> result<_, error-code>;
421
+ /// Return the attributes of an open file or directory.
422
+ ///
423
+ /// Note: This is similar to `fstat` in POSIX, except that it does not return
424
+ /// device and inode information. For testing whether two descriptors refer to
425
+ /// the same underlying filesystem object, use `is-same-object`. To obtain
426
+ /// additional data that can be used do determine whether a file has been
427
+ /// modified, use `metadata-hash`.
428
+ ///
429
+ /// Note: This was called `fd_filestat_get` in earlier versions of WASI.
430
+ @since(version = 0.2.0)
431
+ stat: func() -> result<descriptor-stat, error-code>;
432
+ /// Return the attributes of a file or directory.
433
+ ///
434
+ /// Note: This is similar to `fstatat` in POSIX, except that it does not
435
+ /// return device and inode information. See the `stat` description for a
436
+ /// discussion of alternatives.
437
+ ///
438
+ /// Note: This was called `path_filestat_get` in earlier versions of WASI.
439
+ @since(version = 0.2.0)
440
+ stat-at: func(path-flags: path-flags, path: string) -> result<descriptor-stat, error-code>;
441
+ /// Adjust the timestamps of a file or directory.
442
+ ///
443
+ /// Note: This is similar to `utimensat` in POSIX.
444
+ ///
445
+ /// Note: This was called `path_filestat_set_times` in earlier versions of
446
+ /// WASI.
447
+ @since(version = 0.2.0)
448
+ set-times-at: func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>;
449
+ /// Create a hard link.
450
+ ///
451
+ /// Fails with `error-code::no-entry` if the old path does not exist,
452
+ /// with `error-code::exist` if the new path already exists, and
453
+ /// `error-code::not-permitted` if the old path is not a file.
454
+ ///
455
+ /// Note: This is similar to `linkat` in POSIX.
456
+ @since(version = 0.2.0)
457
+ link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow<descriptor>, new-path: string) -> result<_, error-code>;
458
+ /// Open a file or directory.
459
+ ///
460
+ /// If `flags` contains `descriptor-flags::mutate-directory`, and the base
461
+ /// descriptor doesn't have `descriptor-flags::mutate-directory` set,
462
+ /// `open-at` fails with `error-code::read-only`.
463
+ ///
464
+ /// If `flags` contains `write` or `mutate-directory`, or `open-flags`
465
+ /// contains `truncate` or `create`, and the base descriptor doesn't have
466
+ /// `descriptor-flags::mutate-directory` set, `open-at` fails with
467
+ /// `error-code::read-only`.
468
+ ///
469
+ /// Note: This is similar to `openat` in POSIX.
470
+ @since(version = 0.2.0)
471
+ open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result<descriptor, error-code>;
472
+ /// Read the contents of a symbolic link.
473
+ ///
474
+ /// If the contents contain an absolute or rooted path in the underlying
475
+ /// filesystem, this function fails with `error-code::not-permitted`.
476
+ ///
477
+ /// Note: This is similar to `readlinkat` in POSIX.
478
+ @since(version = 0.2.0)
479
+ readlink-at: func(path: string) -> result<string, error-code>;
480
+ /// Remove a directory.
481
+ ///
482
+ /// Return `error-code::not-empty` if the directory is not empty.
483
+ ///
484
+ /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
485
+ @since(version = 0.2.0)
486
+ remove-directory-at: func(path: string) -> result<_, error-code>;
487
+ /// Rename a filesystem object.
488
+ ///
489
+ /// Note: This is similar to `renameat` in POSIX.
490
+ @since(version = 0.2.0)
491
+ rename-at: func(old-path: string, new-descriptor: borrow<descriptor>, new-path: string) -> result<_, error-code>;
492
+ /// Create a symbolic link (also known as a "symlink").
493
+ ///
494
+ /// If `old-path` starts with `/`, the function fails with
495
+ /// `error-code::not-permitted`.
496
+ ///
497
+ /// Note: This is similar to `symlinkat` in POSIX.
498
+ @since(version = 0.2.0)
499
+ symlink-at: func(old-path: string, new-path: string) -> result<_, error-code>;
500
+ /// Unlink a filesystem object that is not a directory.
501
+ ///
502
+ /// Return `error-code::is-directory` if the path refers to a directory.
503
+ /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
504
+ @since(version = 0.2.0)
505
+ unlink-file-at: func(path: string) -> result<_, error-code>;
506
+ /// Test whether two descriptors refer to the same filesystem object.
507
+ ///
508
+ /// In POSIX, this corresponds to testing whether the two descriptors have the
509
+ /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
510
+ /// wasi-filesystem does not expose device and inode numbers, so this function
511
+ /// may be used instead.
512
+ @since(version = 0.2.0)
513
+ is-same-object: func(other: borrow<descriptor>) -> bool;
514
+ /// Return a hash of the metadata associated with a filesystem object referred
515
+ /// to by a descriptor.
516
+ ///
517
+ /// This returns a hash of the last-modification timestamp and file size, and
518
+ /// may also include the inode number, device number, birth timestamp, and
519
+ /// other metadata fields that may change when the file is modified or
520
+ /// replaced. It may also include a secret value chosen by the
521
+ /// implementation and not otherwise exposed.
522
+ ///
523
+ /// Implementations are encouraged to provide the following properties:
524
+ ///
525
+ /// - If the file is not modified or replaced, the computed hash value should
526
+ /// usually not change.
527
+ /// - If the object is modified or replaced, the computed hash value should
528
+ /// usually change.
529
+ /// - The inputs to the hash should not be easily computable from the
530
+ /// computed hash.
531
+ ///
532
+ /// However, none of these is required.
533
+ @since(version = 0.2.0)
534
+ metadata-hash: func() -> result<metadata-hash-value, error-code>;
535
+ /// Return a hash of the metadata associated with a filesystem object referred
536
+ /// to by a directory descriptor and a relative path.
537
+ ///
538
+ /// This performs the same hash computation as `metadata-hash`.
539
+ @since(version = 0.2.0)
540
+ metadata-hash-at: func(path-flags: path-flags, path: string) -> result<metadata-hash-value, error-code>;
541
+ }
542
+
543
+ /// A stream of directory entries.
544
+ @since(version = 0.2.0)
545
+ resource directory-entry-stream {
546
+ /// Read a single directory entry from a `directory-entry-stream`.
547
+ @since(version = 0.2.0)
548
+ read-directory-entry: func() -> result<option<directory-entry>, error-code>;
549
+ }
550
+
551
+ /// Attempts to extract a filesystem-related `error-code` from the stream
552
+ /// `error` provided.
553
+ ///
554
+ /// Stream operations which return `stream-error::last-operation-failed`
555
+ /// have a payload with more information about the operation that failed.
556
+ /// This payload can be passed through to this function to see if there's
557
+ /// filesystem-related information about the error to return.
558
+ ///
559
+ /// Note that this function is fallible because not all stream-related
560
+ /// errors are filesystem-related errors.
561
+ @since(version = 0.2.0)
562
+ filesystem-error-code: func(err: borrow<error>) -> option<error-code>;
563
+ }
564
+
565
+ @since(version = 0.2.0)
566
+ interface preopens {
567
+ @since(version = 0.2.0)
568
+ use types.{descriptor};
569
+
570
+ /// Return the set of preopened directories, and their paths.
571
+ @since(version = 0.2.0)
572
+ get-directories: func() -> list<tuple<descriptor, string>>;
573
+ }
574
+
575
+ @since(version = 0.2.0)
576
+ world imports {
577
+ @since(version = 0.2.0)
578
+ import wasi:io/error@0.2.12;
579
+ @since(version = 0.2.0)
580
+ import wasi:io/poll@0.2.12;
581
+ @since(version = 0.2.0)
582
+ import wasi:io/streams@0.2.12;
583
+ @since(version = 0.2.0)
584
+ import wasi:clocks/wall-clock@0.2.12;
585
+ @since(version = 0.2.0)
586
+ import types;
587
+ @since(version = 0.2.0)
588
+ import preopens;
589
+ }