Skip to content

Commit a752b5d

Browse files
committed
Simplify examples
1 parent 7b2cc07 commit a752b5d

File tree

4 files changed

+47
-292
lines changed

4 files changed

+47
-292
lines changed
Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
11
package wasi:clocks;
2-
/// WASI Wall Clock is a clock API intended to let users query the current
3-
/// time.
2+
43
interface wall-clock {
5-
/// A time and date in seconds plus nanoseconds.
64
record datetime {
75
seconds: u64,
86
nanoseconds: u32,
97
}
108

11-
/// Read the current value of the clock.
12-
///
13-
/// This clock is not monotonic, therefore calling this function repeatedly
14-
/// will not necessarily produce a sequence of non-decreasing values.
15-
///
16-
/// The returned timestamps represent the number of seconds since
17-
/// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
18-
/// also known as [Unix Time].
19-
///
20-
/// The nanoseconds field of the output is always less than 1000000000.
21-
///
22-
/// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
23-
/// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
249
now: func() -> datetime;
25-
26-
/// Query the resolution of the clock.
27-
///
28-
/// The nanoseconds field of the output is always less than 1000000000.
29-
resolution: func() -> datetime;
3010
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package wasi:clocks;
22

33
world imports {
4-
import monotonic-clock;
54
import wall-clock;
65
}

component-model/examples/wit-section-examples/filesystems/types.wit

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,19 @@
11
package wasi:filesystem;
22
interface types {
3-
use wasi:clocks/wall-clock.{datetime};
43

5-
/// File size or length of a region within a file.
6-
type filesize = u64;
7-
8-
/// The type of a filesystem object referenced by a descriptor.
9-
enum descriptor-type {
10-
/// The descriptor refers to a directory inode.
11-
directory,
12-
/// The descriptor refers to a regular file inode.
13-
regular-file,
14-
}
15-
16-
/// File attributes.
17-
record descriptor-stat {
18-
/// File type.
19-
%type: descriptor-type,
20-
/// File size in bytes.
21-
size: filesize,
22-
/// Last data access timestamp (optional).
23-
data-access-timestamp: option<datetime>,
24-
}
25-
26-
/// Open flags used by `open-at`.
27-
flags open-flags {
28-
/// Create file if it does not exist, similar to `O_CREAT` in POSIX.
29-
create,
30-
/// Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
31-
directory,
32-
}
33-
34-
/// When setting a timestamp, this gives the value to set it to.
35-
variant new-timestamp {
36-
/// Leave the timestamp set to its previous value.
37-
no-change,
38-
/// Set the timestamp to the current time of the system clock associated
39-
/// with the filesystem.
40-
now,
41-
/// Set the timestamp to the given value.
42-
timestamp(datetime),
43-
}
44-
45-
/// Error codes returned by functions, similar to `errno` in POSIX.
464
enum error-code {
47-
/// Permission denied, similar to `EACCES` in POSIX.
485
access,
49-
/// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
50-
would-block,
51-
/// Connection already in progress, similar to `EALREADY` in POSIX.
52-
already,
53-
/// Bad descriptor, similar to `EBADF` in POSIX.
546
bad-descriptor,
55-
/// Device or resource busy, similar to `EBUSY` in POSIX.
56-
busy,
577
}
588

59-
/// A descriptor is a reference to a filesystem object, which may be a
60-
/// file or directory.
619
resource descriptor {
62-
/// Read from a descriptor, without using and updating the descriptor's offset.
63-
///
64-
/// This function returns a list of bytes containing the data that was
65-
/// read, along with a bool which, when true, indicates that the end of the
66-
/// file was reached.
6710
read: func(
68-
/// The maximum number of bytes to read.
6911
length: filesize,
70-
/// The offset within the file at which to read.
7112
offset: filesize,
7213
) -> result<tuple<list<u8>, bool>, error-code>;
7314

74-
/// Return the attributes of an open file or directory.
75-
stat: func() -> result<descriptor-stat, error-code>;
76-
77-
/// Adjust the timestamps of a file or directory.
78-
set-times-at: func(
79-
/// The relative path of the file or directory to operate on.
80-
path: string,
81-
/// The desired values of the data access timestamp.
82-
data-access-timestamp: new-timestamp,
83-
) -> result<_, error-code>;
84-
85-
/// Open a file or directory.
8615
open-at: func(
87-
/// The relative path of the object to open.
8816
path: string,
89-
/// The method by which to open the file.
90-
open-flags: open-flags,
9117
) -> result<descriptor, error-code>;
9218

9319
}

0 commit comments

Comments
 (0)