-
Notifications
You must be signed in to change notification settings - Fork 241
/
key-value.wit
47 lines (38 loc) · 1.61 KB
/
key-value.wit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
interface key-value {
/// An open key-value store
resource store {
/// Open the store with the specified label.
///
/// `label` must refer to a store allowed in the spin.toml manifest.
///
/// `error::no-such-store` will be raised if the `label` is not recognized.
open: static func(label: string) -> result<store, error>;
/// Get the value associated with the specified `key`
///
/// Returns `ok(none)` if the key does not exist.
get: func(key: string) -> result<option<list<u8>>, error>;
/// Set the `value` associated with the specified `key` overwriting any existing value.
set: func(key: string, value: list<u8>) -> result<_, error>;
/// Delete the tuple with the specified `key`
///
/// No error is raised if a tuple did not previously exist for `key`.
delete: func(key: string) -> result<_, error>;
/// Return whether a tuple exists for the specified `key`
exists: func(key: string) -> result<bool, error>;
/// Return a list of all the keys
get-keys: func() -> result<list<string>, error>;
}
/// The set of errors which may be raised by functions in this interface
variant error {
/// Too many stores have been opened simultaneously. Closing one or more
/// stores prior to retrying may address this.
store-table-full,
/// The host does not recognize the store label requested.
no-such-store,
/// The requesting component does not have access to the specified store
/// (which may or may not exist).
access-denied,
/// Some implementation-specific error has occurred (e.g. I/O)
other(string)
}
}