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,299 @@
1
+ package wasi:io@0.2.12;
2
+
3
+ @since(version = 0.2.0)
4
+ interface error {
5
+ /// A resource which represents some error information.
6
+ ///
7
+ /// The only method provided by this resource is `to-debug-string`,
8
+ /// which provides some human-readable information about the error.
9
+ ///
10
+ /// In the `wasi:io` package, this resource is returned through the
11
+ /// `wasi:io/streams.stream-error` type.
12
+ ///
13
+ /// To provide more specific error information, other interfaces may
14
+ /// offer functions to "downcast" this error into more specific types. For example,
15
+ /// errors returned from streams derived from filesystem types can be described using
16
+ /// the filesystem's own error-code type. This is done using the function
17
+ /// `wasi:filesystem/types.filesystem-error-code`, which takes a `borrow<error>`
18
+ /// parameter and returns an `option<wasi:filesystem/types.error-code>`.
19
+ ///
20
+ /// The set of functions which can "downcast" an `error` into a more
21
+ /// concrete type is open.
22
+ @since(version = 0.2.0)
23
+ resource error {
24
+ /// Returns a string that is suitable to assist humans in debugging
25
+ /// this error.
26
+ ///
27
+ /// WARNING: The returned string should not be consumed mechanically!
28
+ /// It may change across platforms, hosts, or other implementation
29
+ /// details. Parsing this string is a major platform-compatibility
30
+ /// hazard.
31
+ @since(version = 0.2.0)
32
+ to-debug-string: func() -> string;
33
+ }
34
+ }
35
+
36
+ /// A poll API intended to let users wait for I/O events on multiple handles
37
+ /// at once.
38
+ @since(version = 0.2.0)
39
+ interface poll {
40
+ /// `pollable` represents a single I/O event which may be ready, or not.
41
+ @since(version = 0.2.0)
42
+ resource pollable {
43
+ /// Return the readiness of a pollable. This function never blocks.
44
+ ///
45
+ /// Returns `true` when the pollable is ready, and `false` otherwise.
46
+ @since(version = 0.2.0)
47
+ ready: func() -> bool;
48
+ /// `block` returns immediately if the pollable is ready, and otherwise
49
+ /// blocks until ready.
50
+ ///
51
+ /// This function is equivalent to calling `poll.poll` on a list
52
+ /// containing only this pollable.
53
+ @since(version = 0.2.0)
54
+ block: func();
55
+ }
56
+
57
+ /// Poll for completion on a set of pollables.
58
+ ///
59
+ /// This function takes a list of pollables, which identify I/O sources of
60
+ /// interest, and waits until one or more of the events is ready for I/O.
61
+ ///
62
+ /// The result `list<u32>` contains one or more indices of handles in the
63
+ /// argument list that is ready for I/O.
64
+ ///
65
+ /// This function traps if either:
66
+ /// - the list is empty, or:
67
+ /// - the list contains more elements than can be indexed with a `u32` value.
68
+ ///
69
+ /// A timeout can be implemented by adding a pollable from the
70
+ /// wasi-clocks API to the list.
71
+ ///
72
+ /// This function does not return a `result`; polling in itself does not
73
+ /// do any I/O so it doesn't fail. If any of the I/O sources identified by
74
+ /// the pollables has an error, it is indicated by marking the source as
75
+ /// being ready for I/O.
76
+ @since(version = 0.2.0)
77
+ poll: func(in: list<borrow<pollable>>) -> list<u32>;
78
+ }
79
+
80
+ /// WASI I/O is an I/O abstraction API which is currently focused on providing
81
+ /// stream types.
82
+ ///
83
+ /// In the future, the component model is expected to add built-in stream types;
84
+ /// when it does, they are expected to subsume this API.
85
+ @since(version = 0.2.0)
86
+ interface streams {
87
+ @since(version = 0.2.0)
88
+ use error.{error};
89
+ @since(version = 0.2.0)
90
+ use poll.{pollable};
91
+
92
+ /// An error for input-stream and output-stream operations.
93
+ @since(version = 0.2.0)
94
+ variant stream-error {
95
+ /// The last operation (a write or flush) failed before completion.
96
+ ///
97
+ /// More information is available in the `error` payload.
98
+ ///
99
+ /// After this, the stream will be closed. All future operations return
100
+ /// `stream-error::closed`.
101
+ last-operation-failed(error),
102
+ /// The stream is closed: no more input will be accepted by the
103
+ /// stream. A closed output-stream will return this error on all
104
+ /// future operations.
105
+ closed,
106
+ }
107
+
108
+ /// An input bytestream.
109
+ ///
110
+ /// `input-stream`s are *non-blocking* to the extent practical on underlying
111
+ /// platforms. I/O operations always return promptly; if fewer bytes are
112
+ /// promptly available than requested, they return the number of bytes promptly
113
+ /// available, which could even be zero. To wait for data to be available,
114
+ /// use the `subscribe` function to obtain a `pollable` which can be polled
115
+ /// for using `wasi:io/poll`.
116
+ @since(version = 0.2.0)
117
+ resource input-stream {
118
+ /// Perform a non-blocking read from the stream.
119
+ ///
120
+ /// When the source of a `read` is binary data, the bytes from the source
121
+ /// are returned verbatim. When the source of a `read` is known to the
122
+ /// implementation to be text, bytes containing the UTF-8 encoding of the
123
+ /// text are returned.
124
+ ///
125
+ /// This function returns a list of bytes containing the read data,
126
+ /// when successful. The returned list will contain up to `len` bytes;
127
+ /// it may return fewer than requested, but not more. The list is
128
+ /// empty when no bytes are available for reading at this time. The
129
+ /// pollable given by `subscribe` will be ready when more bytes are
130
+ /// available.
131
+ ///
132
+ /// This function fails with a `stream-error` when the operation
133
+ /// encounters an error, giving `last-operation-failed`, or when the
134
+ /// stream is closed, giving `closed`.
135
+ ///
136
+ /// When the caller gives a `len` of 0, it represents a request to
137
+ /// read 0 bytes. If the stream is still open, this call should
138
+ /// succeed and return an empty list, or otherwise fail with `closed`.
139
+ ///
140
+ /// The `len` parameter is a `u64`, which could represent a list of u8 which
141
+ /// is not possible to allocate in wasm32, or not desirable to allocate as
142
+ /// as a return value by the callee. The callee may return a list of bytes
143
+ /// less than `len` in size while more bytes are available for reading.
144
+ @since(version = 0.2.0)
145
+ read: func(len: u64) -> result<list<u8>, stream-error>;
146
+ /// Read bytes from a stream, after blocking until at least one byte can
147
+ /// be read. Except for blocking, behavior is identical to `read`.
148
+ @since(version = 0.2.0)
149
+ blocking-read: func(len: u64) -> result<list<u8>, stream-error>;
150
+ /// Skip bytes from a stream. Returns number of bytes skipped.
151
+ ///
152
+ /// Behaves identical to `read`, except instead of returning a list
153
+ /// of bytes, returns the number of bytes consumed from the stream.
154
+ @since(version = 0.2.0)
155
+ skip: func(len: u64) -> result<u64, stream-error>;
156
+ /// Skip bytes from a stream, after blocking until at least one byte
157
+ /// can be skipped. Except for blocking behavior, identical to `skip`.
158
+ @since(version = 0.2.0)
159
+ blocking-skip: func(len: u64) -> result<u64, stream-error>;
160
+ /// Create a `pollable` which will resolve once either the specified stream
161
+ /// has bytes available to read or the other end of the stream has been
162
+ /// closed.
163
+ /// The created `pollable` is a child resource of the `input-stream`.
164
+ /// Implementations may trap if the `input-stream` is dropped before
165
+ /// all derived `pollable`s created with this function are dropped.
166
+ @since(version = 0.2.0)
167
+ subscribe: func() -> pollable;
168
+ }
169
+
170
+ /// An output bytestream.
171
+ ///
172
+ /// `output-stream`s are *non-blocking* to the extent practical on
173
+ /// underlying platforms. Except where specified otherwise, I/O operations also
174
+ /// always return promptly, after the number of bytes that can be written
175
+ /// promptly, which could even be zero. To wait for the stream to be ready to
176
+ /// accept data, the `subscribe` function to obtain a `pollable` which can be
177
+ /// polled for using `wasi:io/poll`.
178
+ ///
179
+ /// Dropping an `output-stream` while there's still an active write in
180
+ /// progress may result in the data being lost. Before dropping the stream,
181
+ /// be sure to fully flush your writes.
182
+ @since(version = 0.2.0)
183
+ resource output-stream {
184
+ /// Check readiness for writing. This function never blocks.
185
+ ///
186
+ /// Returns the number of bytes permitted for the next call to `write`,
187
+ /// or an error. Calling `write` with more bytes than this function has
188
+ /// permitted will trap.
189
+ ///
190
+ /// When this function returns 0 bytes, the `subscribe` pollable will
191
+ /// become ready when this function will report at least 1 byte, or an
192
+ /// error.
193
+ @since(version = 0.2.0)
194
+ check-write: func() -> result<u64, stream-error>;
195
+ /// Perform a write. This function never blocks.
196
+ ///
197
+ /// When the destination of a `write` is binary data, the bytes from
198
+ /// `contents` are written verbatim. When the destination of a `write` is
199
+ /// known to the implementation to be text, the bytes of `contents` are
200
+ /// transcoded from UTF-8 into the encoding of the destination and then
201
+ /// written.
202
+ ///
203
+ /// Precondition: check-write gave permit of Ok(n) and contents has a
204
+ /// length of less than or equal to n. Otherwise, this function will trap.
205
+ ///
206
+ /// returns Err(closed) without writing if the stream has closed since
207
+ /// the last call to check-write provided a permit.
208
+ @since(version = 0.2.0)
209
+ write: func(contents: list<u8>) -> result<_, stream-error>;
210
+ /// Perform a write of up to 4096 bytes, and then flush the stream. Block
211
+ /// until all of these operations are complete, or an error occurs.
212
+ ///
213
+ /// Returns success when all of the contents written are successfully
214
+ /// flushed to output. If an error occurs at any point before all
215
+ /// contents are successfully flushed, that error is returned as soon as
216
+ /// possible. If writing and flushing the complete contents causes the
217
+ /// stream to become closed, this call should return success, and
218
+ /// subsequent calls to check-write or other interfaces should return
219
+ /// stream-error::closed.
220
+ @since(version = 0.2.0)
221
+ blocking-write-and-flush: func(contents: list<u8>) -> result<_, stream-error>;
222
+ /// Request to flush buffered output. This function never blocks.
223
+ ///
224
+ /// This tells the output-stream that the caller intends any buffered
225
+ /// output to be flushed. the output which is expected to be flushed
226
+ /// is all that has been passed to `write` prior to this call.
227
+ ///
228
+ /// Upon calling this function, the `output-stream` will not accept any
229
+ /// writes (`check-write` will return `ok(0)`) until the flush has
230
+ /// completed. The `subscribe` pollable will become ready when the
231
+ /// flush has completed and the stream can accept more writes.
232
+ @since(version = 0.2.0)
233
+ flush: func() -> result<_, stream-error>;
234
+ /// Request to flush buffered output, and block until flush completes
235
+ /// and stream is ready for writing again.
236
+ @since(version = 0.2.0)
237
+ blocking-flush: func() -> result<_, stream-error>;
238
+ /// Create a `pollable` which will resolve once the output-stream
239
+ /// is ready for more writing, or an error has occurred. When this
240
+ /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an
241
+ /// error.
242
+ ///
243
+ /// If the stream is closed, this pollable is always ready immediately.
244
+ ///
245
+ /// The created `pollable` is a child resource of the `output-stream`.
246
+ /// Implementations may trap if the `output-stream` is dropped before
247
+ /// all derived `pollable`s created with this function are dropped.
248
+ @since(version = 0.2.0)
249
+ subscribe: func() -> pollable;
250
+ /// Write zeroes to a stream.
251
+ ///
252
+ /// This should be used precisely like `write` with the exact same
253
+ /// preconditions (must use check-write first), but instead of
254
+ /// passing a list of bytes, you simply pass the number of zero-bytes
255
+ /// that should be written.
256
+ @since(version = 0.2.0)
257
+ write-zeroes: func(len: u64) -> result<_, stream-error>;
258
+ /// Perform a write of up to 4096 zeroes, and then flush the stream.
259
+ /// Block until all of these operations are complete, or an error
260
+ /// occurs.
261
+ ///
262
+ /// Functionality is equivelant to `blocking-write-and-flush` with
263
+ /// contents given as a list of len containing only zeroes.
264
+ @since(version = 0.2.0)
265
+ blocking-write-zeroes-and-flush: func(len: u64) -> result<_, stream-error>;
266
+ /// Read from one stream and write to another.
267
+ ///
268
+ /// The behavior of splice is equivalent to:
269
+ /// 1. calling `check-write` on the `output-stream`
270
+ /// 2. calling `read` on the `input-stream` with the smaller of the
271
+ /// `check-write` permitted length and the `len` provided to `splice`
272
+ /// 3. calling `write` on the `output-stream` with that read data.
273
+ ///
274
+ /// Any error reported by the call to `check-write`, `read`, or
275
+ /// `write` ends the splice and reports that error.
276
+ ///
277
+ /// This function returns the number of bytes transferred; it may be less
278
+ /// than `len`.
279
+ @since(version = 0.2.0)
280
+ splice: func(src: borrow<input-stream>, len: u64) -> result<u64, stream-error>;
281
+ /// Read from one stream and write to another, with blocking.
282
+ ///
283
+ /// This is similar to `splice`, except that it blocks until the
284
+ /// `output-stream` is ready for writing, and the `input-stream`
285
+ /// is ready for reading, before performing the `splice`.
286
+ @since(version = 0.2.0)
287
+ blocking-splice: func(src: borrow<input-stream>, len: u64) -> result<u64, stream-error>;
288
+ }
289
+ }
290
+
291
+ @since(version = 0.2.0)
292
+ world imports {
293
+ @since(version = 0.2.0)
294
+ import error;
295
+ @since(version = 0.2.0)
296
+ import poll;
297
+ @since(version = 0.2.0)
298
+ import streams;
299
+ }
@@ -0,0 +1,92 @@
1
+ package wasi:random@0.2.12;
2
+
3
+ /// The insecure-seed interface for seeding hash-map DoS resistance.
4
+ ///
5
+ /// It is intended to be portable at least between Unix-family platforms and
6
+ /// Windows.
7
+ @since(version = 0.2.0)
8
+ interface insecure-seed {
9
+ /// Return a 128-bit value that may contain a pseudo-random value.
10
+ ///
11
+ /// The returned value is not required to be computed from a CSPRNG, and may
12
+ /// even be entirely deterministic. Host implementations are encouraged to
13
+ /// provide pseudo-random values to any program exposed to
14
+ /// attacker-controlled content, to enable DoS protection built into many
15
+ /// languages' hash-map implementations.
16
+ ///
17
+ /// This function is intended to only be called once, by a source language
18
+ /// to initialize Denial Of Service (DoS) protection in its hash-map
19
+ /// implementation.
20
+ ///
21
+ /// # Expected future evolution
22
+ ///
23
+ /// This will likely be changed to a value import, to prevent it from being
24
+ /// called multiple times and potentially used for purposes other than DoS
25
+ /// protection.
26
+ @since(version = 0.2.0)
27
+ insecure-seed: func() -> tuple<u64, u64>;
28
+ }
29
+
30
+ /// The insecure interface for insecure pseudo-random numbers.
31
+ ///
32
+ /// It is intended to be portable at least between Unix-family platforms and
33
+ /// Windows.
34
+ @since(version = 0.2.0)
35
+ interface insecure {
36
+ /// Return `len` insecure pseudo-random bytes.
37
+ ///
38
+ /// This function is not cryptographically secure. Do not use it for
39
+ /// anything related to security.
40
+ ///
41
+ /// There are no requirements on the values of the returned bytes, however
42
+ /// implementations are encouraged to return evenly distributed values with
43
+ /// a long period.
44
+ @since(version = 0.2.0)
45
+ get-insecure-random-bytes: func(len: u64) -> list<u8>;
46
+
47
+ /// Return an insecure pseudo-random `u64` value.
48
+ ///
49
+ /// This function returns the same type of pseudo-random data as
50
+ /// `get-insecure-random-bytes`, represented as a `u64`.
51
+ @since(version = 0.2.0)
52
+ get-insecure-random-u64: func() -> u64;
53
+ }
54
+
55
+ /// WASI Random is a random data API.
56
+ ///
57
+ /// It is intended to be portable at least between Unix-family platforms and
58
+ /// Windows.
59
+ @since(version = 0.2.0)
60
+ interface random {
61
+ /// Return `len` cryptographically-secure random or pseudo-random bytes.
62
+ ///
63
+ /// This function must produce data at least as cryptographically secure and
64
+ /// fast as an adequately seeded cryptographically-secure pseudo-random
65
+ /// number generator (CSPRNG). It must not block, from the perspective of
66
+ /// the calling program, under any circumstances, including on the first
67
+ /// request and on requests for numbers of bytes. The returned data must
68
+ /// always be unpredictable.
69
+ ///
70
+ /// This function must always return fresh data. Deterministic environments
71
+ /// must omit this function, rather than implementing it with deterministic
72
+ /// data.
73
+ @since(version = 0.2.0)
74
+ get-random-bytes: func(len: u64) -> list<u8>;
75
+
76
+ /// Return a cryptographically-secure random or pseudo-random `u64` value.
77
+ ///
78
+ /// This function returns the same type of data as `get-random-bytes`,
79
+ /// represented as a `u64`.
80
+ @since(version = 0.2.0)
81
+ get-random-u64: func() -> u64;
82
+ }
83
+
84
+ @since(version = 0.2.0)
85
+ world imports {
86
+ @since(version = 0.2.0)
87
+ import random;
88
+ @since(version = 0.2.0)
89
+ import insecure;
90
+ @since(version = 0.2.0)
91
+ import insecure-seed;
92
+ }