World all

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

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
  • 0: u64
  • 1: u64

tuple b256

256 bit value

Tuple Fields
  • 0: u64
  • 1: u64
  • 2: u64
  • 3: u64

tuple b512

512 bit value

Tuple Fields
  • 0: u64
  • 1: u64
  • 2: u64
  • 3: u64
  • 4: u64
  • 5: u64
  • 6: u64
  • 7: u64

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

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

bstr

#### `type cbor` [`cbor`](#cbor)

#### `type json` [`json`](#json)

#### `variant kv-values`

A time and date in seconds plus nanoseconds.

Variant Cases
  • kv-string: string

  • kv-s64: s64

    A String

  • kv-u64: u64

    Just use the largest signed integer type supported

  • kv-f64: f64

    Just use the largest integer type supported

  • kv-bstr: bstr

    Just use the largest float type supported

  • kv-cbor: cbor

    A byte string

  • kv-json: json

    CBOR 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

kv-get-default: func

Get a value from the local key-value store Returns the default if not set.

Params
Return 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
  • key: string
Return 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
Return 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
Return 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

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
  • key: string
Return 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
  • key: string
Return values

Export interface hermes:kv-store/event


Types

type kv-values

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