|
| 1 | +// A handle to an open key-value store |
| 2 | +type store = u32 |
| 3 | + |
| 4 | +// The set of errors which may be raised by functions in this interface |
| 5 | +variant error { |
| 6 | + // Too many stores have been opened simultaneously. Closing one or more |
| 7 | + // stores prior to retrying may address this. |
| 8 | + store-table-full, |
| 9 | + |
| 10 | + // The host does not recognize the store name requested. Defining and |
| 11 | + // configuring a store with that name in a runtime configuration file |
| 12 | + // may address this. |
| 13 | + no-such-store, |
| 14 | + |
| 15 | + // The requesting component does not have access to the specified store |
| 16 | + // (which may or may not exist). |
| 17 | + access-denied, |
| 18 | + |
| 19 | + // The store handle provided is not recognized, i.e. it was either never |
| 20 | + // opened or has been closed. |
| 21 | + invalid-store, |
| 22 | + |
| 23 | + // No key-value tuple exists for the specified key in the specified |
| 24 | + // store. |
| 25 | + no-such-key, |
| 26 | + |
| 27 | + // Some implementation-specific error has occurred (e.g. I/O) |
| 28 | + io(string) |
| 29 | +} |
| 30 | + |
| 31 | +// Open the store with the specified name. |
| 32 | +// |
| 33 | +// If `name` is "default", the default store is opened. Otherwise, |
| 34 | +// `name` must refer to a store defined and configured in a runtime |
| 35 | +// configuration file supplied with the application. |
| 36 | +// |
| 37 | +// `error::no-such-store` will be raised if the `name` is not recognized. |
| 38 | +open: func(name: string) -> expected<store, error> |
| 39 | + |
| 40 | +// Get the value associated with the specified `key` from the specified |
| 41 | +// `store`. |
| 42 | +// |
| 43 | +// `error::invalid-store` will be raised if `store` is not a valid handle |
| 44 | +// to an open store, and `error::no-such-key` will be raised if there is no |
| 45 | +// tuple for `key` in `store`. |
| 46 | +get: func(store: store, key: string) -> expected<list<u8>, error> |
| 47 | + |
| 48 | +// Set the `value` associated with the specified `key` in the specified |
| 49 | +// `store`, overwriting any existing value. |
| 50 | +// |
| 51 | +// `error::invalid-store` will be raised if `store` is not a valid handle |
| 52 | +// to an open store. |
| 53 | +set: func(store: store, key: string, value: list<u8>) -> expected<unit, error> |
| 54 | + |
| 55 | +// Delete the tuple with the specified `key` from the specified `store`. |
| 56 | +// |
| 57 | +// `error::invalid-store` will be raised if `store` is not a valid handle |
| 58 | +// to an open store. No error is raised if a tuple did not previously |
| 59 | +// exist for `key`. |
| 60 | +delete: func(store: store, key: string) -> expected<unit, error> |
| 61 | + |
| 62 | +// Return whether a tuple exists for the specified `key` in the specified |
| 63 | +// `store`. |
| 64 | +// |
| 65 | +// `error::invalid-store` will be raised if `store` is not a valid handle |
| 66 | +// to an open store. |
| 67 | +exists: func(store: store, key: string) -> expected<bool, error> |
| 68 | + |
| 69 | +// Return a list of all the keys in the specified `store`. |
| 70 | +// |
| 71 | +// `error::invalid-store` will be raised if `store` is not a valid handle |
| 72 | +// to an open store. |
| 73 | +get-keys: func(store: store) -> expected<list<string>, error> |
| 74 | + |
| 75 | +// Close the specified `store`. |
| 76 | +// |
| 77 | +// This has no effect if `store` is not a valid handle to an open store. |
| 78 | +close: func(store: store) |
0 commit comments