World all
- Imports:
- interface
hermes:binary/api - interface
hermes:cbor/api - interface
hermes:json/api - interface
hermes:kv-store/api
- interface
- Exports:
- interface
hermes:kv-store/event
- interface
Import interface hermes:binary/api
Binary Data API
Binary Data types and functions.
Permissions
This API is ALWAYS available. cspell: words Binary API Interface - Imports ONLY
Types
type bstr
Binary String (bstr) is a list of bytes. This type is used to indicate the data is an arbitrary array of bytes.
tuple b128
128 bit value
Tuple Fields
tuple b256
256 bit value
Tuple Fields
tuple b512
512 bit value
Tuple Fields
Import interface hermes:cbor/api
CBOR API
CBOR Data types and functions.
Permissions
This API is ALWAYS available. cspell: words CBOR API Interface - Imports ONLY
Types
type bstr
#### `type cbor` [`bstr`](#bstr)
CBOR is a binary cbor data type. This type is used to indicate the binary array MUST be CBOR data.
Import interface hermes:json/api
JSON API
JSON Data types and functions.
Permissions
This API is ALWAYS available. cspell: words JSON API Interface - Imports ONLY
Types
type json
string
JSON is just a string. This type is used to indicate the string MUST be properly formatted JSON.
Import interface hermes:kv-store/api
Interface to local in-memory K-V database instance.
This API is atomic. It is safe to call it from multiple wasm modules in the same application. The atomic nature of these calls allows multiple wasm modules to communicate without data race conditions through the KV store.
These are primitive operations, and the caller is expected to provide more complex semaphore/mutex logic on top of these building blocks, if required.
There is no support for multi-key atomic operations, the application is required to manage multi-key updates given the functionality provided here. For example, a single Key could be used to "Lock" a set of other keys.
There is no protection against deadlock, if a key is used as a semaphore/mutex then it is the responsibility of the applications modules to properly manage them.
Types
type bstr
#### `type cbor` [`cbor`](#cbor)
#### `type json` [`json`](#json)
A time and date in seconds plus nanoseconds.
Variant Cases
-
A String
-
Just use the largest signed integer type supported
-
Just use the largest integer type supported
-
kv-bstr:bstrJust use the largest float type supported
-
kv-cbor:cborA byte string
-
kv-json:jsonCBOR data
Functions
kv-set: func
Set a value in the local key-value store Setting None will cause the Key to be deleted from the KV store.
Params
key:stringvalue: option<kv-values>
kv-get-default: func
Get a value from the local key-value store Returns the default if not set.
Params
key:stringdefault: option<kv-values>
Return values
- option<
kv-values>
kv-get: func
Get a value from the local key-value store
Returns None if the Key does not exist in the KV Store.
This is a convenience function, and is equivalent to kv-get-default(key, none)
Params
Return values
- option<
kv-values>
kv-get-set: func
Get a value, and then set it (Atomic) Setting None will cause the Key to be deleted from the KV store.
Params
key:stringvalue: option<kv-values>
Return values
- option<
kv-values>
kv-add: func
Get a value, and then add to it (Atomic)
Adding to a string will concatenate the string.
String concatenation will only occur up to the maximum possible size of a string value.
Concatenation beyond the maximum size will result in truncation.
Adding to a numeric will have the expected behavior (rounded to nearest if necessary).
The original type does not change, so: f64 + u64 = f64. s64 + f64 = s64
If the value overflows or under-flows it will saturate at the limit.
This behavior allows us to decrement values by using the signed version, so u64(10) + s64(-5) = u64(5))
If a string is added to a numeric, nothing happens.
If a numeric is added to a string, it is converted to a string first, and then concatenated
Note: There will be no spaces added. So "My string" + u32(77) = "My string77"
Params
key:stringvalue: option<kv-values>
Return values
- option<
kv-values>
kv-cas: func
Check if the Key equals a test value (exact match) and if it does, store the new value.
In all cases, the current value is returned.
If the types are NOT the same, the comparison will fail, even if the values are equivalent.
For example: u64(7) != s64(7), f64(-1) != s64(-1).
Params
Return values
- option<
kv-values>
kv-subscribe: func
Subscribe to any updates made to a particular Key. After this call, this module will receive Key Update events when a key is written. It returns the current value of the Key and None if it is not set.
Params
Return values
- option<
kv-values>
kv-unsubscribe: func
Unsubscribe to any updates made to a particular Key. After this call, this module will no longer receive Key Update events when a key is written. It returns the current value of the Key and None if it is not set.
Params
Return values
- option<
kv-values>
Export interface hermes:kv-store/event
Types
type kv-values
----
Functions
kv-update: func
A Subscribed key has updated.
This will only ever be called if the module has subscribed to updates using
kv-subscribe
Returns: Nothing.
Params
key:stringvalue:kv-values