From 44bb36307a771469dca6cb67e3e489a54f65a773 Mon Sep 17 00:00:00 2001
From: "Jiaxiao Zhou (Mossaka)"
wasi:io/error@0.2.0-rc-2023-11-10
wasi:io/poll@0.2.0-rc-2023-11-10
wasi:io/streams@0.2.0-rc-2023-11-10
wasi:keyvalue/wasi-keyvalue-error
wasi:keyvalue/types
wasi:keyvalue/eventual
wasi:keyvalue/atomic
wasi:keyvalue/eventual-batch
wasi:keyvalue/wasi-keyvalue-error@0.1.0
wasi:keyvalue/types@0.1.0
wasi:keyvalue/eventual@0.1.0
wasi:keyvalue/atomic@0.1.0
wasi:keyvalue/eventual-batch@0.1.0
resource error
resource error
A resource which represents some error information.
The only method provided by this resource is to-debug-string
,
which provides some human-readable information about the error.
error
into a more
concrete type is open.[method]error.to-debug-string: func
[method]error.to-debug-string: func
Returns a string that is suitable to assist humans in debugging this error.
WARNING: The returned string should not be consumed mechanically! @@ -50,41 +50,41 @@ details. Parsing this string is a major platform-compatibility hazard.
A poll API intended to let users wait for I/O events on multiple handles at once.
resource pollable
resource pollable
pollable
epresents a single I/O event which may be ready, or not.[method]pollable.ready: func
[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
Returns true
when the pollable is ready, and false
otherwise.
[method]pollable.block: func
[method]pollable.block: func
block
returns immediately if the pollable is ready, and otherwise
blocks until ready.
This function is equivalent to calling poll.poll
on a list
containing only this pollable.
poll: func
poll: func
Poll for completion on a set of pollables.
This function takes a list of pollables, which identify I/O sources of interest, and waits until one or more of the events is ready for I/O.
@@ -100,42 +100,42 @@ the pollables has an error, it is indicated by marking the source as being reaedy for I/O.WASI I/O is an I/O abstraction API which is currently focused on providing stream types.
In the future, the component model is expected to add built-in stream types; when it does, they are expected to subsume this API.
type error
type error
-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)
-#### `variant stream-error` +#### `variant stream-error`
An error for input-stream and output-stream operations.
last-operation-failed
: own<error
>
last-operation-failed
: own<error
>
The last operation (a write or flush) failed before completion.
More information is available in the error
payload.
The stream is closed: no more input will be accepted by the stream. A closed output-stream will return this error on all future operations.
resource input-stream
resource input-stream
An input bytestream.
input-stream
s are non-blocking to the extent practical on underlying
platforms. I/O operations always return promptly; if fewer bytes are
@@ -143,7 +143,7 @@ promptly available than requested, they return the number of bytes promptly
available, which could even be zero. To wait for data to be available,
use the subscribe
function to obtain a pollable
which can be polled
for using wasi:io/poll
.
resource output-stream
resource output-stream
An output bytestream.
output-stream
s are non-blocking to the extent practical on
underlying platforms. Except where specified otherwise, I/O operations also
@@ -152,7 +152,7 @@ promptly, which could even be zero. To wait for the stream to be ready to
accept data, the subscribe
function to obtain a pollable
which can be
polled for using wasi:io/poll
.[method]input-stream.read: func
[method]input-stream.read: func
Perform a non-blocking read from the stream.
This function returns a list of bytes containing the read data,
when successful. The returned list will contain up to len
bytes;
@@ -172,51 +172,51 @@ as a return value by the callee. The callee may return a list of bytes
less than len
in size while more bytes are available for reading.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.blocking-read: func
[method]input-stream.blocking-read: func
Read bytes from a stream, after blocking until at least one byte can
be read. Except for blocking, behavior is identical to read
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.skip: func
[method]input-stream.skip: func
Skip bytes from a stream. Returns number of bytes skipped.
Behaves identical to read
, except instead of returning a list
of bytes, returns the number of bytes consumed from the stream.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.blocking-skip: func
[method]input-stream.blocking-skip: func
Skip bytes from a stream, after blocking until at least one byte
can be skipped. Except for blocking behavior, identical to skip
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.subscribe: func
[method]input-stream.subscribe: func
Create a pollable
which will resolve once either the specified stream
has bytes available to read or the other end of the stream has been
closed.
@@ -225,13 +225,13 @@ Implementations may trap if the input-stream
pollable
s created with this function are dropped.
self
: borrow<input-stream
>self
: borrow<input-stream
>pollable
>[method]output-stream.check-write: func
[method]output-stream.check-write: func
Check readiness for writing. This function never blocks.
Returns the number of bytes permitted for the next call to write
,
or an error. Calling write
with more bytes than this function has
@@ -241,13 +241,13 @@ become ready when this function will report at least 1 byte, or an
error.
self
: borrow<output-stream
>self
: borrow<output-stream
>u64
, stream-error
>[method]output-stream.write: func
[method]output-stream.write: func
Perform a write. This function never blocks.
Precondition: check-write gave permit of Ok(n) and contents has a length of less than or equal to n. Otherwise, this function will trap.
@@ -255,14 +255,14 @@ length of less than or equal to n. Otherwise, this function will trap. the last call to check-write provided a permit.self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.blocking-write-and-flush: func
[method]output-stream.blocking-write-and-flush: func
Perform a write of up to 4096 bytes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
This is a convenience wrapper around the use of check-write
,
@@ -286,14 +286,14 @@ let _ = this.check-write(); // eliding error handling
self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.flush: func
[method]output-stream.flush: func
Request to flush buffered output. This function never blocks.
This tells the output-stream that the caller intends any buffered
output to be flushed. the output which is expected to be flushed
@@ -304,24 +304,24 @@ completed. The subscribe
pollable will become ready when the
flush has completed and the stream can accept more writes.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.blocking-flush: func
[method]output-stream.blocking-flush: func
Request to flush buffered output, and block until flush completes and stream is ready for writing again.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.subscribe: func
[method]output-stream.subscribe: func
Create a pollable
which will resolve once the output-stream
is ready for more writing, or an error has occured. When this
pollable is ready, check-write
will return ok(n)
with n>0, or an
@@ -332,13 +332,13 @@ Implementations may trap if the output-stream
s created with this function are dropped.pollable
self
: borrow<output-stream
>self
: borrow<output-stream
>pollable
>[method]output-stream.write-zeroes: func
[method]output-stream.write-zeroes: func
Write zeroes to a stream.
this should be used precisely like write
with the exact same
preconditions (must use check-write first), but instead of
@@ -346,14 +346,14 @@ passing a list of bytes, you simply pass the number of zero-bytes
that should be written.
self
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.blocking-write-zeroes-and-flush: func
[method]output-stream.blocking-write-zeroes-and-flush: func
Perform a write of up to 4096 zeroes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
@@ -377,14 +377,14 @@ let _ = this.check-write(); // eliding error handlingself
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.splice: func
[method]output-stream.splice: func
Read from one stream and write to another.
The behavior of splice is equivelant to:
len
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]output-stream.blocking-splice: func
[method]output-stream.blocking-splice: func
Read from one stream and write to another, with blocking.
This is similar to splice
, except that it blocks until the
output-stream
is ready for writing, and the input-stream
is ready for reading, before performing the splice
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>resource error
resource error
An error resource type for keyvalue operations.
Common errors:
resource error { ... }
[method]error.trace: func
[method]error.trace: func
A generic keyvalue interface for WASI.
type input-stream
type input-stream
-#### `type output-stream` +#### `type output-stream` [`output-stream`](#output_stream)
-#### `type error` +#### `type error` [`error`](#error)
-#### `resource bucket` +#### `resource bucket`
A bucket is a collection of key-value pairs. Each key-value pair is stored as a entry in the bucket, and the bucket itself acts as a collection of all these entries.
@@ -481,22 +481,22 @@ can very depending on the specific implementation. For example,In this interface, we use the term bucket
to refer to a collection of key-value
Soon: switch to resource bucket { ... }
type key
type key
string
A key is a unique identifier for a value in a bucket. The key is used to retrieve the value from the bucket. -
resource outgoing-value
resource outgoing-value
A value is the data stored in a key-value pair. The value can be of any type
that can be represented in a byte array. It provides a way to write the value
to the output-stream defined in the wasi-io
interface.
Soon: switch to resource value { ... }
type outgoing-value-body-async
type outgoing-value-body-async
-#### `type outgoing-value-body-sync` +#### `type outgoing-value-body-sync` [`outgoing-value-body-sync`](#outgoing_value_body_sync)
-#### `resource incoming-value` +#### `resource incoming-value`
A incoming-value is a wrapper around a value. It provides a way to read the value
from the input-stream
defined in the wasi-io
interface.
The incoming-value provides two ways to consume the value:
@@ -510,87 +510,87 @@ This is useful when the value is large and the caller wants to allocate a buffer the right size to consume the value. Soon: switch toresource incoming-value { ... }
-type incoming-value-async-body
type incoming-value-async-body
-#### `type incoming-value-sync-body` +#### `type incoming-value-sync-body` [`incoming-value-sync-body`](#incoming_value_sync_body)
----
[static]bucket.open-bucket: func
[static]bucket.open-bucket: func
Opens a bucket with the given name.
If any error occurs, including if the bucket does not exist, it returns an Err(error)
.
name
: string
name
: string
[static]outgoing-value.new-outgoing-value: func
[static]outgoing-value.new-outgoing-value: func
outgoing-value
>[method]outgoing-value.outgoing-value-write-body-async: func
[method]outgoing-value.outgoing-value-write-body-async: func
Writes the value to the output-stream asynchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>self
: borrow<outgoing-value
>outgoing-value-body-async
>, own<error
>>[method]outgoing-value.outgoing-value-write-body-sync: func
[method]outgoing-value.outgoing-value-write-body-sync: func
Writes the value to the output-stream synchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
error
>>[method]incoming-value.incoming-value-consume-sync: func
[method]incoming-value.incoming-value-consume-sync: func
Consumes the value synchronously and returns the value as a list of bytes.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-sync-body
, own<error
>>[method]incoming-value.incoming-value-consume-async: func
[method]incoming-value.incoming-value-consume-async: func
Consumes the value asynchronously and returns the value as an input-stream
.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-async-body
>, own<error
>>[method]incoming-value.incoming-value-size: func
[method]incoming-value.incoming-value-size: func
The size of the value in bytes.
If the size is unknown or unavailable, this function returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>u64
, own<error
>>A keyvalue interface that provides eventually consistent CRUD operations.
A CRUD operation is an operation that acts on a single key-value pair.
The value in the key-value pair is defined as a u8
byte array and the intention
@@ -609,24 +609,24 @@ if we pause the updates to the system, the system eventually will return
the last updated value for read.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get: func
get: func
Get the value associated with the key in the bucket.
The value is returned as an option. If the key-value pair exists in the
bucket, it returns Ok(value)
. If the key does not exist in the
@@ -634,56 +634,56 @@ bucket, it returns Ok(none)
.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>, own<error
>>set: func
set: func
Set the value associated with the key in the bucket. If the key already exists in the bucket, it overwrites the value.
If the key does not exist in the bucket, it creates a new key-value pair.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>error
>>delete: func
delete: func
Delete the key-value pair associated with the key in the bucket.
If the key does not exist in the bucket, it does nothing.
If any other error occurs, it returns an Err(error)
.
error
>>exists: func
exists: func
Check if the key exists in the bucket.
If the key exists in the bucket, it returns Ok(true)
. If the key does
not exist in the bucket, it returns Ok(false)
.
If any other error occurs, it returns an Err(error)
.
bool
, own<error
>>A keyvalue interface that provides atomic operations.
Atomic operations are single, indivisible operations. When a fault causes an atomic operation to fail, it will appear to the invoker of the atomic @@ -691,18 +691,18 @@ operation that the action either completed successfully or did nothing at all.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
----
increment: func
increment: func
Atomically increment the value associated with the key in the bucket by the given delta. It returns the new value.
If the key does not exist in the bucket, it creates a new key-value pair @@ -710,15 +710,15 @@ with the value set to the given delta.
If any other error occurs, it returns an Err(error)
.
u64
, own<error
>>compare-and-swap: func
compare-and-swap: func
Compare-and-swap (CAS) atomically updates the value associated with the key
in the bucket if the value matches the old value. This operation returns
Ok(true)
if the swap was successful, Ok(false)
if the value did not match,
new
value.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bool
, own<error
>>A keyvalue interface that provides eventually consistent batch operations.
A batch operation is an operation that operates on multiple keys at once.
Batch operations are useful for reducing network round-trip time. For example, @@ -757,24 +757,24 @@ meaning that if a write operation completes, subsequent read operations may not the value that was written.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get-many: func
get-many: func
Get the values associated with the keys in the bucket. It returns a list of incoming-value that can be consumed to get the value associated with the key.
If any of the keys do not exist in the bucket, it returns a none
value for
@@ -784,14 +784,14 @@ that key in the list.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>>, own<error
>>keys: func
keys: func
Get all the keys in the bucket. It returns a list of keys.
Note that the keys are not guaranteed to be returned in any particular order.
If the bucket is empty, it returns an empty list.
@@ -799,13 +799,13 @@ that key in the list.If any error occurs, it returns an Err(error)
.
set-many: func
set-many: func
Set the values associated with the keys in the bucket. If the key already exists in the bucket, it overwrites the value.
Note that the key-value pairs are not guaranteed to be set in the order @@ -818,14 +818,14 @@ set while others might fail.
Other concurrent operations may also be able to see the partial results.
bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>error
>>delete-many: func
delete-many: func
Delete the key-value pairs associated with the keys in the bucket.
Note that the key-value pairs are not guaranteed to be deleted in the order they are provided.
@@ -837,8 +837,8 @@ deleted while others might fail.Other concurrent operations may also be able to see the partial results.
wasi:io/error@0.2.0-rc-2023-11-10
wasi:io/poll@0.2.0-rc-2023-11-10
wasi:io/streams@0.2.0-rc-2023-11-10
wasi:keyvalue/wasi-keyvalue-error
wasi:keyvalue/types
wasi:keyvalue/eventual
wasi:keyvalue/atomic
wasi:keyvalue/eventual-batch
wasi:keyvalue/wasi-keyvalue-error@0.1.0
wasi:keyvalue/types@0.1.0
wasi:keyvalue/eventual@0.1.0
wasi:keyvalue/atomic@0.1.0
wasi:keyvalue/eventual-batch@0.1.0
wasi:keyvalue/handle-watch
wasi:keyvalue/handle-watch@0.1.0
resource error
resource error
A resource which represents some error information.
The only method provided by this resource is to-debug-string
,
which provides some human-readable information about the error.
error
into a more
concrete type is open.[method]error.to-debug-string: func
[method]error.to-debug-string: func
Returns a string that is suitable to assist humans in debugging this error.
WARNING: The returned string should not be consumed mechanically! @@ -47,41 +47,41 @@ details. Parsing this string is a major platform-compatibility hazard.
A poll API intended to let users wait for I/O events on multiple handles at once.
resource pollable
resource pollable
pollable
epresents a single I/O event which may be ready, or not.[method]pollable.ready: func
[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
Returns true
when the pollable is ready, and false
otherwise.
[method]pollable.block: func
[method]pollable.block: func
block
returns immediately if the pollable is ready, and otherwise
blocks until ready.
This function is equivalent to calling poll.poll
on a list
containing only this pollable.
poll: func
poll: func
Poll for completion on a set of pollables.
This function takes a list of pollables, which identify I/O sources of interest, and waits until one or more of the events is ready for I/O.
@@ -97,42 +97,42 @@ the pollables has an error, it is indicated by marking the source as being reaedy for I/O.WASI I/O is an I/O abstraction API which is currently focused on providing stream types.
In the future, the component model is expected to add built-in stream types; when it does, they are expected to subsume this API.
type error
type error
-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)
-#### `variant stream-error` +#### `variant stream-error`
An error for input-stream and output-stream operations.
last-operation-failed
: own<error
>
last-operation-failed
: own<error
>
The last operation (a write or flush) failed before completion.
More information is available in the error
payload.
The stream is closed: no more input will be accepted by the stream. A closed output-stream will return this error on all future operations.
resource input-stream
resource input-stream
An input bytestream.
input-stream
s are non-blocking to the extent practical on underlying
platforms. I/O operations always return promptly; if fewer bytes are
@@ -140,7 +140,7 @@ promptly available than requested, they return the number of bytes promptly
available, which could even be zero. To wait for data to be available,
use the subscribe
function to obtain a pollable
which can be polled
for using wasi:io/poll
.
resource output-stream
resource output-stream
An output bytestream.
output-stream
s are non-blocking to the extent practical on
underlying platforms. Except where specified otherwise, I/O operations also
@@ -149,7 +149,7 @@ promptly, which could even be zero. To wait for the stream to be ready to
accept data, the subscribe
function to obtain a pollable
which can be
polled for using wasi:io/poll
.[method]input-stream.read: func
[method]input-stream.read: func
Perform a non-blocking read from the stream.
This function returns a list of bytes containing the read data,
when successful. The returned list will contain up to len
bytes;
@@ -169,51 +169,51 @@ as a return value by the callee. The callee may return a list of bytes
less than len
in size while more bytes are available for reading.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.blocking-read: func
[method]input-stream.blocking-read: func
Read bytes from a stream, after blocking until at least one byte can
be read. Except for blocking, behavior is identical to read
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.skip: func
[method]input-stream.skip: func
Skip bytes from a stream. Returns number of bytes skipped.
Behaves identical to read
, except instead of returning a list
of bytes, returns the number of bytes consumed from the stream.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.blocking-skip: func
[method]input-stream.blocking-skip: func
Skip bytes from a stream, after blocking until at least one byte
can be skipped. Except for blocking behavior, identical to skip
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.subscribe: func
[method]input-stream.subscribe: func
Create a pollable
which will resolve once either the specified stream
has bytes available to read or the other end of the stream has been
closed.
@@ -222,13 +222,13 @@ Implementations may trap if the input-stream
pollable
s created with this function are dropped.
self
: borrow<input-stream
>self
: borrow<input-stream
>pollable
>[method]output-stream.check-write: func
[method]output-stream.check-write: func
Check readiness for writing. This function never blocks.
Returns the number of bytes permitted for the next call to write
,
or an error. Calling write
with more bytes than this function has
@@ -238,13 +238,13 @@ become ready when this function will report at least 1 byte, or an
error.
self
: borrow<output-stream
>self
: borrow<output-stream
>u64
, stream-error
>[method]output-stream.write: func
[method]output-stream.write: func
Perform a write. This function never blocks.
Precondition: check-write gave permit of Ok(n) and contents has a length of less than or equal to n. Otherwise, this function will trap.
@@ -252,14 +252,14 @@ length of less than or equal to n. Otherwise, this function will trap. the last call to check-write provided a permit.self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.blocking-write-and-flush: func
[method]output-stream.blocking-write-and-flush: func
Perform a write of up to 4096 bytes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
This is a convenience wrapper around the use of check-write
,
@@ -283,14 +283,14 @@ let _ = this.check-write(); // eliding error handling
self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.flush: func
[method]output-stream.flush: func
Request to flush buffered output. This function never blocks.
This tells the output-stream that the caller intends any buffered
output to be flushed. the output which is expected to be flushed
@@ -301,24 +301,24 @@ completed. The subscribe
pollable will become ready when the
flush has completed and the stream can accept more writes.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.blocking-flush: func
[method]output-stream.blocking-flush: func
Request to flush buffered output, and block until flush completes and stream is ready for writing again.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.subscribe: func
[method]output-stream.subscribe: func
Create a pollable
which will resolve once the output-stream
is ready for more writing, or an error has occured. When this
pollable is ready, check-write
will return ok(n)
with n>0, or an
@@ -329,13 +329,13 @@ Implementations may trap if the output-stream
s created with this function are dropped.pollable
self
: borrow<output-stream
>self
: borrow<output-stream
>pollable
>[method]output-stream.write-zeroes: func
[method]output-stream.write-zeroes: func
Write zeroes to a stream.
this should be used precisely like write
with the exact same
preconditions (must use check-write first), but instead of
@@ -343,14 +343,14 @@ passing a list of bytes, you simply pass the number of zero-bytes
that should be written.
self
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.blocking-write-zeroes-and-flush: func
[method]output-stream.blocking-write-zeroes-and-flush: func
Perform a write of up to 4096 zeroes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
@@ -374,14 +374,14 @@ let _ = this.check-write(); // eliding error handlingself
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.splice: func
[method]output-stream.splice: func
Read from one stream and write to another.
The behavior of splice is equivelant to:
len
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]output-stream.blocking-splice: func
[method]output-stream.blocking-splice: func
Read from one stream and write to another, with blocking.
This is similar to splice
, except that it blocks until the
output-stream
is ready for writing, and the input-stream
is ready for reading, before performing the splice
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>resource error
resource error
An error resource type for keyvalue operations.
Common errors:
resource error { ... }
[method]error.trace: func
[method]error.trace: func
A generic keyvalue interface for WASI.
type input-stream
type input-stream
-#### `type output-stream` +#### `type output-stream` [`output-stream`](#output_stream)
-#### `type error` +#### `type error` [`error`](#error)
-#### `resource bucket` +#### `resource bucket`
A bucket is a collection of key-value pairs. Each key-value pair is stored as a entry in the bucket, and the bucket itself acts as a collection of all these entries.
@@ -478,22 +478,22 @@ can very depending on the specific implementation. For example,In this interface, we use the term bucket
to refer to a collection of key-value
Soon: switch to resource bucket { ... }
type key
type key
string
A key is a unique identifier for a value in a bucket. The key is used to retrieve the value from the bucket. -
resource outgoing-value
resource outgoing-value
A value is the data stored in a key-value pair. The value can be of any type
that can be represented in a byte array. It provides a way to write the value
to the output-stream defined in the wasi-io
interface.
Soon: switch to resource value { ... }
type outgoing-value-body-async
type outgoing-value-body-async
-#### `type outgoing-value-body-sync` +#### `type outgoing-value-body-sync` [`outgoing-value-body-sync`](#outgoing_value_body_sync)
-#### `resource incoming-value` +#### `resource incoming-value`
A incoming-value is a wrapper around a value. It provides a way to read the value
from the input-stream
defined in the wasi-io
interface.
The incoming-value provides two ways to consume the value:
@@ -507,87 +507,87 @@ This is useful when the value is large and the caller wants to allocate a buffer the right size to consume the value. Soon: switch toresource incoming-value { ... }
-type incoming-value-async-body
type incoming-value-async-body
-#### `type incoming-value-sync-body` +#### `type incoming-value-sync-body` [`incoming-value-sync-body`](#incoming_value_sync_body)
----
[static]bucket.open-bucket: func
[static]bucket.open-bucket: func
Opens a bucket with the given name.
If any error occurs, including if the bucket does not exist, it returns an Err(error)
.
name
: string
name
: string
[static]outgoing-value.new-outgoing-value: func
[static]outgoing-value.new-outgoing-value: func
outgoing-value
>[method]outgoing-value.outgoing-value-write-body-async: func
[method]outgoing-value.outgoing-value-write-body-async: func
Writes the value to the output-stream asynchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>self
: borrow<outgoing-value
>outgoing-value-body-async
>, own<error
>>[method]outgoing-value.outgoing-value-write-body-sync: func
[method]outgoing-value.outgoing-value-write-body-sync: func
Writes the value to the output-stream synchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
error
>>[method]incoming-value.incoming-value-consume-sync: func
[method]incoming-value.incoming-value-consume-sync: func
Consumes the value synchronously and returns the value as a list of bytes.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-sync-body
, own<error
>>[method]incoming-value.incoming-value-consume-async: func
[method]incoming-value.incoming-value-consume-async: func
Consumes the value asynchronously and returns the value as an input-stream
.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-async-body
>, own<error
>>[method]incoming-value.incoming-value-size: func
[method]incoming-value.incoming-value-size: func
The size of the value in bytes.
If the size is unknown or unavailable, this function returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>u64
, own<error
>>A keyvalue interface that provides eventually consistent CRUD operations.
A CRUD operation is an operation that acts on a single key-value pair.
The value in the key-value pair is defined as a u8
byte array and the intention
@@ -606,24 +606,24 @@ if we pause the updates to the system, the system eventually will return
the last updated value for read.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get: func
get: func
Get the value associated with the key in the bucket.
The value is returned as an option. If the key-value pair exists in the
bucket, it returns Ok(value)
. If the key does not exist in the
@@ -631,56 +631,56 @@ bucket, it returns Ok(none)
.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>, own<error
>>set: func
set: func
Set the value associated with the key in the bucket. If the key already exists in the bucket, it overwrites the value.
If the key does not exist in the bucket, it creates a new key-value pair.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>error
>>delete: func
delete: func
Delete the key-value pair associated with the key in the bucket.
If the key does not exist in the bucket, it does nothing.
If any other error occurs, it returns an Err(error)
.
error
>>exists: func
exists: func
Check if the key exists in the bucket.
If the key exists in the bucket, it returns Ok(true)
. If the key does
not exist in the bucket, it returns Ok(false)
.
If any other error occurs, it returns an Err(error)
.
bool
, own<error
>>A keyvalue interface that provides atomic operations.
Atomic operations are single, indivisible operations. When a fault causes an atomic operation to fail, it will appear to the invoker of the atomic @@ -688,18 +688,18 @@ operation that the action either completed successfully or did nothing at all.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
----
increment: func
increment: func
Atomically increment the value associated with the key in the bucket by the given delta. It returns the new value.
If the key does not exist in the bucket, it creates a new key-value pair @@ -707,15 +707,15 @@ with the value set to the given delta.
If any other error occurs, it returns an Err(error)
.
u64
, own<error
>>compare-and-swap: func
compare-and-swap: func
Compare-and-swap (CAS) atomically updates the value associated with the key
in the bucket if the value matches the old value. This operation returns
Ok(true)
if the swap was successful, Ok(false)
if the value did not match,
new
value.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bool
, own<error
>>A keyvalue interface that provides eventually consistent batch operations.
A batch operation is an operation that operates on multiple keys at once.
Batch operations are useful for reducing network round-trip time. For example, @@ -754,24 +754,24 @@ meaning that if a write operation completes, subsequent read operations may not the value that was written.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get-many: func
get-many: func
Get the values associated with the keys in the bucket. It returns a list of incoming-value that can be consumed to get the value associated with the key.
If any of the keys do not exist in the bucket, it returns a none
value for
@@ -781,14 +781,14 @@ that key in the list.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>>, own<error
>>keys: func
keys: func
Get all the keys in the bucket. It returns a list of keys.
Note that the keys are not guaranteed to be returned in any particular order.
If the bucket is empty, it returns an empty list.
@@ -796,13 +796,13 @@ that key in the list.If any error occurs, it returns an Err(error)
.
set-many: func
set-many: func
Set the values associated with the keys in the bucket. If the key already exists in the bucket, it overwrites the value.
Note that the key-value pairs are not guaranteed to be set in the order @@ -815,14 +815,14 @@ set while others might fail.
Other concurrent operations may also be able to see the partial results.
bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>error
>>delete-many: func
delete-many: func
Delete the key-value pairs associated with the keys in the bucket.
Note that the key-value pairs are not guaranteed to be deleted in the order they are provided.
@@ -834,42 +834,42 @@ deleted while others might fail.Other concurrent operations may also be able to see the partial results.
error
>>type bucket
type bucket
-#### `type key` +#### `type key` [`key`](#key)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
----
on-set: func
on-set: func
Handle the set
event for the given bucket and key.
It returns a incoming-value
that represents the new value being set.
The new value can be consumed by the handler.
bucket
: own<bucket
>key
: key
incoming-value
: borrow<incoming-value
>bucket
: own<bucket
>key
: key
incoming-value
: borrow<incoming-value
>on-delete: func
on-delete: func
Handle the delete
event for the given bucket and key.
It returns a key
that represents the key being deleted.
resource error
resource error
A resource which represents some error information.
The only method provided by this resource is to-debug-string
,
which provides some human-readable information about the error.
error
into a more
concrete type is open.[method]error.to-debug-string: func
[method]error.to-debug-string: func
Returns a string that is suitable to assist humans in debugging this error.
WARNING: The returned string should not be consumed mechanically! @@ -50,41 +50,41 @@ details. Parsing this string is a major platform-compatibility hazard.
A poll API intended to let users wait for I/O events on multiple handles at once.
resource pollable
resource pollable
pollable
epresents a single I/O event which may be ready, or not.[method]pollable.ready: func
[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
Returns true
when the pollable is ready, and false
otherwise.
[method]pollable.block: func
[method]pollable.block: func
block
returns immediately if the pollable is ready, and otherwise
blocks until ready.
This function is equivalent to calling poll.poll
on a list
containing only this pollable.
poll: func
poll: func
Poll for completion on a set of pollables.
This function takes a list of pollables, which identify I/O sources of interest, and waits until one or more of the events is ready for I/O.
@@ -100,42 +100,42 @@ the pollables has an error, it is indicated by marking the source as being reaedy for I/O.WASI I/O is an I/O abstraction API which is currently focused on providing stream types.
In the future, the component model is expected to add built-in stream types; when it does, they are expected to subsume this API.
type error
type error
-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)
-#### `variant stream-error` +#### `variant stream-error`
An error for input-stream and output-stream operations.
last-operation-failed
: own<error
>
last-operation-failed
: own<error
>
The last operation (a write or flush) failed before completion.
More information is available in the error
payload.
The stream is closed: no more input will be accepted by the stream. A closed output-stream will return this error on all future operations.
resource input-stream
resource input-stream
An input bytestream.
input-stream
s are non-blocking to the extent practical on underlying
platforms. I/O operations always return promptly; if fewer bytes are
@@ -143,7 +143,7 @@ promptly available than requested, they return the number of bytes promptly
available, which could even be zero. To wait for data to be available,
use the subscribe
function to obtain a pollable
which can be polled
for using wasi:io/poll
.
resource output-stream
resource output-stream
An output bytestream.
output-stream
s are non-blocking to the extent practical on
underlying platforms. Except where specified otherwise, I/O operations also
@@ -152,7 +152,7 @@ promptly, which could even be zero. To wait for the stream to be ready to
accept data, the subscribe
function to obtain a pollable
which can be
polled for using wasi:io/poll
.[method]input-stream.read: func
[method]input-stream.read: func
Perform a non-blocking read from the stream.
This function returns a list of bytes containing the read data,
when successful. The returned list will contain up to len
bytes;
@@ -172,51 +172,51 @@ as a return value by the callee. The callee may return a list of bytes
less than len
in size while more bytes are available for reading.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.blocking-read: func
[method]input-stream.blocking-read: func
Read bytes from a stream, after blocking until at least one byte can
be read. Except for blocking, behavior is identical to read
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.skip: func
[method]input-stream.skip: func
Skip bytes from a stream. Returns number of bytes skipped.
Behaves identical to read
, except instead of returning a list
of bytes, returns the number of bytes consumed from the stream.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.blocking-skip: func
[method]input-stream.blocking-skip: func
Skip bytes from a stream, after blocking until at least one byte
can be skipped. Except for blocking behavior, identical to skip
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.subscribe: func
[method]input-stream.subscribe: func
Create a pollable
which will resolve once either the specified stream
has bytes available to read or the other end of the stream has been
closed.
@@ -225,13 +225,13 @@ Implementations may trap if the input-stream
pollable
s created with this function are dropped.
self
: borrow<input-stream
>self
: borrow<input-stream
>pollable
>[method]output-stream.check-write: func
[method]output-stream.check-write: func
Check readiness for writing. This function never blocks.
Returns the number of bytes permitted for the next call to write
,
or an error. Calling write
with more bytes than this function has
@@ -241,13 +241,13 @@ become ready when this function will report at least 1 byte, or an
error.
self
: borrow<output-stream
>self
: borrow<output-stream
>u64
, stream-error
>[method]output-stream.write: func
[method]output-stream.write: func
Perform a write. This function never blocks.
Precondition: check-write gave permit of Ok(n) and contents has a length of less than or equal to n. Otherwise, this function will trap.
@@ -255,14 +255,14 @@ length of less than or equal to n. Otherwise, this function will trap. the last call to check-write provided a permit.self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.blocking-write-and-flush: func
[method]output-stream.blocking-write-and-flush: func
Perform a write of up to 4096 bytes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
This is a convenience wrapper around the use of check-write
,
@@ -286,14 +286,14 @@ let _ = this.check-write(); // eliding error handling
self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.flush: func
[method]output-stream.flush: func
Request to flush buffered output. This function never blocks.
This tells the output-stream that the caller intends any buffered
output to be flushed. the output which is expected to be flushed
@@ -304,24 +304,24 @@ completed. The subscribe
pollable will become ready when the
flush has completed and the stream can accept more writes.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.blocking-flush: func
[method]output-stream.blocking-flush: func
Request to flush buffered output, and block until flush completes and stream is ready for writing again.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.subscribe: func
[method]output-stream.subscribe: func
Create a pollable
which will resolve once the output-stream
is ready for more writing, or an error has occured. When this
pollable is ready, check-write
will return ok(n)
with n>0, or an
@@ -332,13 +332,13 @@ Implementations may trap if the output-stream
s created with this function are dropped.pollable
self
: borrow<output-stream
>self
: borrow<output-stream
>pollable
>[method]output-stream.write-zeroes: func
[method]output-stream.write-zeroes: func
Write zeroes to a stream.
this should be used precisely like write
with the exact same
preconditions (must use check-write first), but instead of
@@ -346,14 +346,14 @@ passing a list of bytes, you simply pass the number of zero-bytes
that should be written.
self
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.blocking-write-zeroes-and-flush: func
[method]output-stream.blocking-write-zeroes-and-flush: func
Perform a write of up to 4096 zeroes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
@@ -377,14 +377,14 @@ let _ = this.check-write(); // eliding error handlingself
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.splice: func
[method]output-stream.splice: func
Read from one stream and write to another.
The behavior of splice is equivelant to:
len
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]output-stream.blocking-splice: func
[method]output-stream.blocking-splice: func
Read from one stream and write to another, with blocking.
This is similar to splice
, except that it blocks until the
output-stream
is ready for writing, and the input-stream
is ready for reading, before performing the splice
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>resource error
resource error
An error resource type for keyvalue operations.
Common errors:
resource error { ... }
[method]error.trace: func
[method]error.trace: func
A generic keyvalue interface for WASI.
type input-stream
type input-stream
-#### `type output-stream` +#### `type output-stream` [`output-stream`](#output_stream)
-#### `type error` +#### `type error` [`error`](#error)
-#### `resource bucket` +#### `resource bucket`
A bucket is a collection of key-value pairs. Each key-value pair is stored as a entry in the bucket, and the bucket itself acts as a collection of all these entries.
@@ -481,22 +481,22 @@ can very depending on the specific implementation. For example,In this interface, we use the term bucket
to refer to a collection of key-value
Soon: switch to resource bucket { ... }
type key
type key
string
A key is a unique identifier for a value in a bucket. The key is used to retrieve the value from the bucket. -
resource outgoing-value
resource outgoing-value
A value is the data stored in a key-value pair. The value can be of any type
that can be represented in a byte array. It provides a way to write the value
to the output-stream defined in the wasi-io
interface.
Soon: switch to resource value { ... }
type outgoing-value-body-async
type outgoing-value-body-async
-#### `type outgoing-value-body-sync` +#### `type outgoing-value-body-sync` [`outgoing-value-body-sync`](#outgoing_value_body_sync)
-#### `resource incoming-value` +#### `resource incoming-value`
A incoming-value is a wrapper around a value. It provides a way to read the value
from the input-stream
defined in the wasi-io
interface.
The incoming-value provides two ways to consume the value:
@@ -510,87 +510,87 @@ This is useful when the value is large and the caller wants to allocate a buffer the right size to consume the value. Soon: switch toresource incoming-value { ... }
-type incoming-value-async-body
type incoming-value-async-body
-#### `type incoming-value-sync-body` +#### `type incoming-value-sync-body` [`incoming-value-sync-body`](#incoming_value_sync_body)
----
[static]bucket.open-bucket: func
[static]bucket.open-bucket: func
Opens a bucket with the given name.
If any error occurs, including if the bucket does not exist, it returns an Err(error)
.
name
: string
name
: string
[static]outgoing-value.new-outgoing-value: func
[static]outgoing-value.new-outgoing-value: func
outgoing-value
>[method]outgoing-value.outgoing-value-write-body-async: func
[method]outgoing-value.outgoing-value-write-body-async: func
Writes the value to the output-stream asynchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>self
: borrow<outgoing-value
>outgoing-value-body-async
>, own<error
>>[method]outgoing-value.outgoing-value-write-body-sync: func
[method]outgoing-value.outgoing-value-write-body-sync: func
Writes the value to the output-stream synchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
error
>>[method]incoming-value.incoming-value-consume-sync: func
[method]incoming-value.incoming-value-consume-sync: func
Consumes the value synchronously and returns the value as a list of bytes.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-sync-body
, own<error
>>[method]incoming-value.incoming-value-consume-async: func
[method]incoming-value.incoming-value-consume-async: func
Consumes the value asynchronously and returns the value as an input-stream
.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-async-body
>, own<error
>>[method]incoming-value.incoming-value-size: func
[method]incoming-value.incoming-value-size: func
The size of the value in bytes.
If the size is unknown or unavailable, this function returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>u64
, own<error
>>A keyvalue interface that provides eventually consistent CRUD operations.
A CRUD operation is an operation that acts on a single key-value pair.
The value in the key-value pair is defined as a u8
byte array and the intention
@@ -609,24 +609,24 @@ if we pause the updates to the system, the system eventually will return
the last updated value for read.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get: func
get: func
Get the value associated with the key in the bucket.
The value is returned as an option. If the key-value pair exists in the
bucket, it returns Ok(value)
. If the key does not exist in the
@@ -634,56 +634,56 @@ bucket, it returns Ok(none)
.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>, own<error
>>set: func
set: func
Set the value associated with the key in the bucket. If the key already exists in the bucket, it overwrites the value.
If the key does not exist in the bucket, it creates a new key-value pair.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>error
>>delete: func
delete: func
Delete the key-value pair associated with the key in the bucket.
If the key does not exist in the bucket, it does nothing.
If any other error occurs, it returns an Err(error)
.
error
>>exists: func
exists: func
Check if the key exists in the bucket.
If the key exists in the bucket, it returns Ok(true)
. If the key does
not exist in the bucket, it returns Ok(false)
.
If any other error occurs, it returns an Err(error)
.
bool
, own<error
>>A keyvalue interface that provides atomic operations.
Atomic operations are single, indivisible operations. When a fault causes an atomic operation to fail, it will appear to the invoker of the atomic @@ -691,18 +691,18 @@ operation that the action either completed successfully or did nothing at all.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
----
increment: func
increment: func
Atomically increment the value associated with the key in the bucket by the given delta. It returns the new value.
If the key does not exist in the bucket, it creates a new key-value pair @@ -710,15 +710,15 @@ with the value set to the given delta.
If any other error occurs, it returns an Err(error)
.
u64
, own<error
>>compare-and-swap: func
compare-and-swap: func
Compare-and-swap (CAS) atomically updates the value associated with the key
in the bucket if the value matches the old value. This operation returns
Ok(true)
if the swap was successful, Ok(false)
if the value did not match,
new
value.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bool
, own<error
>>A keyvalue interface that provides eventually consistent batch operations.
A batch operation is an operation that operates on multiple keys at once.
Batch operations are useful for reducing network round-trip time. For example, @@ -757,24 +757,24 @@ meaning that if a write operation completes, subsequent read operations may not the value that was written.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get-many: func
get-many: func
Get the values associated with the keys in the bucket. It returns a list of incoming-value that can be consumed to get the value associated with the key.
If any of the keys do not exist in the bucket, it returns a none
value for
@@ -784,14 +784,14 @@ that key in the list.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>>, own<error
>>keys: func
keys: func
Get all the keys in the bucket. It returns a list of keys.
Note that the keys are not guaranteed to be returned in any particular order.
If the bucket is empty, it returns an empty list.
@@ -799,13 +799,13 @@ that key in the list.If any error occurs, it returns an Err(error)
.
set-many: func
set-many: func
Set the values associated with the keys in the bucket. If the key already exists in the bucket, it overwrites the value.
Note that the key-value pairs are not guaranteed to be set in the order @@ -818,14 +818,14 @@ set while others might fail.
Other concurrent operations may also be able to see the partial results.
bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>error
>>delete-many: func
delete-many: func
Delete the key-value pairs associated with the keys in the bucket.
Note that the key-value pairs are not guaranteed to be deleted in the order they are provided.
@@ -837,8 +837,8 @@ deleted while others might fail.Other concurrent operations may also be able to see the partial results.
resource error
resource error
A resource which represents some error information.
The only method provided by this resource is to-debug-string
,
which provides some human-readable information about the error.
error
into a more
concrete type is open.[method]error.to-debug-string: func
[method]error.to-debug-string: func
Returns a string that is suitable to assist humans in debugging this error.
WARNING: The returned string should not be consumed mechanically! @@ -47,41 +47,41 @@ details. Parsing this string is a major platform-compatibility hazard.
A poll API intended to let users wait for I/O events on multiple handles at once.
resource pollable
resource pollable
pollable
epresents a single I/O event which may be ready, or not.[method]pollable.ready: func
[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
Returns true
when the pollable is ready, and false
otherwise.
[method]pollable.block: func
[method]pollable.block: func
block
returns immediately if the pollable is ready, and otherwise
blocks until ready.
This function is equivalent to calling poll.poll
on a list
containing only this pollable.
poll: func
poll: func
Poll for completion on a set of pollables.
This function takes a list of pollables, which identify I/O sources of interest, and waits until one or more of the events is ready for I/O.
@@ -97,42 +97,42 @@ the pollables has an error, it is indicated by marking the source as being reaedy for I/O.WASI I/O is an I/O abstraction API which is currently focused on providing stream types.
In the future, the component model is expected to add built-in stream types; when it does, they are expected to subsume this API.
type error
type error
-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)
-#### `variant stream-error` +#### `variant stream-error`
An error for input-stream and output-stream operations.
last-operation-failed
: own<error
>
last-operation-failed
: own<error
>
The last operation (a write or flush) failed before completion.
More information is available in the error
payload.
The stream is closed: no more input will be accepted by the stream. A closed output-stream will return this error on all future operations.
resource input-stream
resource input-stream
An input bytestream.
input-stream
s are non-blocking to the extent practical on underlying
platforms. I/O operations always return promptly; if fewer bytes are
@@ -140,7 +140,7 @@ promptly available than requested, they return the number of bytes promptly
available, which could even be zero. To wait for data to be available,
use the subscribe
function to obtain a pollable
which can be polled
for using wasi:io/poll
.
resource output-stream
resource output-stream
An output bytestream.
output-stream
s are non-blocking to the extent practical on
underlying platforms. Except where specified otherwise, I/O operations also
@@ -149,7 +149,7 @@ promptly, which could even be zero. To wait for the stream to be ready to
accept data, the subscribe
function to obtain a pollable
which can be
polled for using wasi:io/poll
.[method]input-stream.read: func
[method]input-stream.read: func
Perform a non-blocking read from the stream.
This function returns a list of bytes containing the read data,
when successful. The returned list will contain up to len
bytes;
@@ -169,51 +169,51 @@ as a return value by the callee. The callee may return a list of bytes
less than len
in size while more bytes are available for reading.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.blocking-read: func
[method]input-stream.blocking-read: func
Read bytes from a stream, after blocking until at least one byte can
be read. Except for blocking, behavior is identical to read
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>[method]input-stream.skip: func
[method]input-stream.skip: func
Skip bytes from a stream. Returns number of bytes skipped.
Behaves identical to read
, except instead of returning a list
of bytes, returns the number of bytes consumed from the stream.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.blocking-skip: func
[method]input-stream.blocking-skip: func
Skip bytes from a stream, after blocking until at least one byte
can be skipped. Except for blocking behavior, identical to skip
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]input-stream.subscribe: func
[method]input-stream.subscribe: func
Create a pollable
which will resolve once either the specified stream
has bytes available to read or the other end of the stream has been
closed.
@@ -222,13 +222,13 @@ Implementations may trap if the input-stream
pollable
s created with this function are dropped.
self
: borrow<input-stream
>self
: borrow<input-stream
>pollable
>[method]output-stream.check-write: func
[method]output-stream.check-write: func
Check readiness for writing. This function never blocks.
Returns the number of bytes permitted for the next call to write
,
or an error. Calling write
with more bytes than this function has
@@ -238,13 +238,13 @@ become ready when this function will report at least 1 byte, or an
error.
self
: borrow<output-stream
>self
: borrow<output-stream
>u64
, stream-error
>[method]output-stream.write: func
[method]output-stream.write: func
Perform a write. This function never blocks.
Precondition: check-write gave permit of Ok(n) and contents has a length of less than or equal to n. Otherwise, this function will trap.
@@ -252,14 +252,14 @@ length of less than or equal to n. Otherwise, this function will trap. the last call to check-write provided a permit.self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.blocking-write-and-flush: func
[method]output-stream.blocking-write-and-flush: func
Perform a write of up to 4096 bytes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
This is a convenience wrapper around the use of check-write
,
@@ -283,14 +283,14 @@ let _ = this.check-write(); // eliding error handling
self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>[method]output-stream.flush: func
[method]output-stream.flush: func
Request to flush buffered output. This function never blocks.
This tells the output-stream that the caller intends any buffered
output to be flushed. the output which is expected to be flushed
@@ -301,24 +301,24 @@ completed. The subscribe
pollable will become ready when the
flush has completed and the stream can accept more writes.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.blocking-flush: func
[method]output-stream.blocking-flush: func
Request to flush buffered output, and block until flush completes and stream is ready for writing again.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>[method]output-stream.subscribe: func
[method]output-stream.subscribe: func
Create a pollable
which will resolve once the output-stream
is ready for more writing, or an error has occured. When this
pollable is ready, check-write
will return ok(n)
with n>0, or an
@@ -329,13 +329,13 @@ Implementations may trap if the output-stream
s created with this function are dropped.pollable
self
: borrow<output-stream
>self
: borrow<output-stream
>pollable
>[method]output-stream.write-zeroes: func
[method]output-stream.write-zeroes: func
Write zeroes to a stream.
this should be used precisely like write
with the exact same
preconditions (must use check-write first), but instead of
@@ -343,14 +343,14 @@ passing a list of bytes, you simply pass the number of zero-bytes
that should be written.
self
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.blocking-write-zeroes-and-flush: func
[method]output-stream.blocking-write-zeroes-and-flush: func
Perform a write of up to 4096 zeroes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
@@ -374,14 +374,14 @@ let _ = this.check-write(); // eliding error handlingself
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>[method]output-stream.splice: func
[method]output-stream.splice: func
Read from one stream and write to another.
The behavior of splice is equivelant to:
len
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>[method]output-stream.blocking-splice: func
[method]output-stream.blocking-splice: func
Read from one stream and write to another, with blocking.
This is similar to splice
, except that it blocks until the
output-stream
is ready for writing, and the input-stream
is ready for reading, before performing the splice
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>resource error
resource error
An error resource type for keyvalue operations.
Common errors:
resource error { ... }
[method]error.trace: func
[method]error.trace: func
A generic keyvalue interface for WASI.
type input-stream
type input-stream
-#### `type output-stream` +#### `type output-stream` [`output-stream`](#output_stream)
-#### `type error` +#### `type error` [`error`](#error)
-#### `resource bucket` +#### `resource bucket`
A bucket is a collection of key-value pairs. Each key-value pair is stored as a entry in the bucket, and the bucket itself acts as a collection of all these entries.
@@ -478,22 +478,22 @@ can very depending on the specific implementation. For example,In this interface, we use the term bucket
to refer to a collection of key-value
Soon: switch to resource bucket { ... }
type key
type key
string
A key is a unique identifier for a value in a bucket. The key is used to retrieve the value from the bucket. -
resource outgoing-value
resource outgoing-value
A value is the data stored in a key-value pair. The value can be of any type
that can be represented in a byte array. It provides a way to write the value
to the output-stream defined in the wasi-io
interface.
Soon: switch to resource value { ... }
type outgoing-value-body-async
type outgoing-value-body-async
-#### `type outgoing-value-body-sync` +#### `type outgoing-value-body-sync` [`outgoing-value-body-sync`](#outgoing_value_body_sync)
-#### `resource incoming-value` +#### `resource incoming-value`
A incoming-value is a wrapper around a value. It provides a way to read the value
from the input-stream
defined in the wasi-io
interface.
The incoming-value provides two ways to consume the value:
@@ -507,87 +507,87 @@ This is useful when the value is large and the caller wants to allocate a buffer the right size to consume the value. Soon: switch toresource incoming-value { ... }
-type incoming-value-async-body
type incoming-value-async-body
-#### `type incoming-value-sync-body` +#### `type incoming-value-sync-body` [`incoming-value-sync-body`](#incoming_value_sync_body)
----
[static]bucket.open-bucket: func
[static]bucket.open-bucket: func
Opens a bucket with the given name.
If any error occurs, including if the bucket does not exist, it returns an Err(error)
.
name
: string
name
: string
[static]outgoing-value.new-outgoing-value: func
[static]outgoing-value.new-outgoing-value: func
outgoing-value
>[method]outgoing-value.outgoing-value-write-body-async: func
[method]outgoing-value.outgoing-value-write-body-async: func
Writes the value to the output-stream asynchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>self
: borrow<outgoing-value
>outgoing-value-body-async
>, own<error
>>[method]outgoing-value.outgoing-value-write-body-sync: func
[method]outgoing-value.outgoing-value-write-body-sync: func
Writes the value to the output-stream synchronously.
If any other error occurs, it returns an Err(error)
.
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
self
: borrow<outgoing-value
>value
: outgoing-value-body-sync
error
>>[method]incoming-value.incoming-value-consume-sync: func
[method]incoming-value.incoming-value-consume-sync: func
Consumes the value synchronously and returns the value as a list of bytes.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-sync-body
, own<error
>>[method]incoming-value.incoming-value-consume-async: func
[method]incoming-value.incoming-value-consume-async: func
Consumes the value asynchronously and returns the value as an input-stream
.
If any other error occurs, it returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>incoming-value-async-body
>, own<error
>>[method]incoming-value.incoming-value-size: func
[method]incoming-value.incoming-value-size: func
The size of the value in bytes.
If the size is unknown or unavailable, this function returns an Err(error)
.
self
: borrow<incoming-value
>self
: borrow<incoming-value
>u64
, own<error
>>A keyvalue interface that provides eventually consistent CRUD operations.
A CRUD operation is an operation that acts on a single key-value pair.
The value in the key-value pair is defined as a u8
byte array and the intention
@@ -606,24 +606,24 @@ if we pause the updates to the system, the system eventually will return
the last updated value for read.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get: func
get: func
Get the value associated with the key in the bucket.
The value is returned as an option. If the key-value pair exists in the
bucket, it returns Ok(value)
. If the key does not exist in the
@@ -631,56 +631,56 @@ bucket, it returns Ok(none)
.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>, own<error
>>set: func
set: func
Set the value associated with the key in the bucket. If the key already exists in the bucket, it overwrites the value.
If the key does not exist in the bucket, it creates a new key-value pair.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>bucket
: borrow<bucket
>key
: key
outgoing-value
: borrow<outgoing-value
>error
>>delete: func
delete: func
Delete the key-value pair associated with the key in the bucket.
If the key does not exist in the bucket, it does nothing.
If any other error occurs, it returns an Err(error)
.
error
>>exists: func
exists: func
Check if the key exists in the bucket.
If the key exists in the bucket, it returns Ok(true)
. If the key does
not exist in the bucket, it returns Ok(false)
.
If any other error occurs, it returns an Err(error)
.
bool
, own<error
>>A keyvalue interface that provides atomic operations.
Atomic operations are single, indivisible operations. When a fault causes an atomic operation to fail, it will appear to the invoker of the atomic @@ -688,18 +688,18 @@ operation that the action either completed successfully or did nothing at all.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
----
increment: func
increment: func
Atomically increment the value associated with the key in the bucket by the given delta. It returns the new value.
If the key does not exist in the bucket, it creates a new key-value pair @@ -707,15 +707,15 @@ with the value set to the given delta.
If any other error occurs, it returns an Err(error)
.
u64
, own<error
>>compare-and-swap: func
compare-and-swap: func
Compare-and-swap (CAS) atomically updates the value associated with the key
in the bucket if the value matches the old value. This operation returns
Ok(true)
if the swap was successful, Ok(false)
if the value did not match,
new
value.
If any other error occurs, it returns an Err(error)
.
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bucket
: borrow<bucket
>key
: key
old
: u64
new
: u64
bool
, own<error
>>A keyvalue interface that provides eventually consistent batch operations.
A batch operation is an operation that operates on multiple keys at once.
Batch operations are useful for reducing network round-trip time. For example, @@ -754,24 +754,24 @@ meaning that if a write operation completes, subsequent read operations may not the value that was written.
type bucket
type bucket
-#### `type error` +#### `type error` [`error`](#error)
-#### `type key` +#### `type key` [`key`](#key)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
-#### `type outgoing-value` +#### `type outgoing-value` [`outgoing-value`](#outgoing_value)
----
get-many: func
get-many: func
Get the values associated with the keys in the bucket. It returns a list of incoming-value that can be consumed to get the value associated with the key.
If any of the keys do not exist in the bucket, it returns a none
value for
@@ -781,14 +781,14 @@ that key in the list.
If any other error occurs, it returns an Err(error)
.
incoming-value
>>>, own<error
>>keys: func
keys: func
Get all the keys in the bucket. It returns a list of keys.
Note that the keys are not guaranteed to be returned in any particular order.
If the bucket is empty, it returns an empty list.
@@ -796,13 +796,13 @@ that key in the list.If any error occurs, it returns an Err(error)
.
set-many: func
set-many: func
Set the values associated with the keys in the bucket. If the key already exists in the bucket, it overwrites the value.
Note that the key-value pairs are not guaranteed to be set in the order @@ -815,14 +815,14 @@ set while others might fail.
Other concurrent operations may also be able to see the partial results.
bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>bucket
: borrow<bucket
>key-values
: list<(key
, borrow<outgoing-value
>)>error
>>delete-many: func
delete-many: func
Delete the key-value pairs associated with the keys in the bucket.
Note that the key-value pairs are not guaranteed to be deleted in the order they are provided.
@@ -834,42 +834,42 @@ deleted while others might fail.Other concurrent operations may also be able to see the partial results.
error
>>type bucket
type bucket
-#### `type key` +#### `type key` [`key`](#key)
-#### `type incoming-value` +#### `type incoming-value` [`incoming-value`](#incoming_value)
----
on-set: func
on-set: func
Handle the set
event for the given bucket and key.
It returns a incoming-value
that represents the new value being set.
The new value can be consumed by the handler.
bucket
: own<bucket
>key
: key
incoming-value
: borrow<incoming-value
>bucket
: own<bucket
>key
: key
incoming-value
: borrow<incoming-value
>on-delete: func
on-delete: func
Handle the delete
event for the given bucket and key.
It returns a key
that represents the key being deleted.