Module Octez_riscv_nds_common.Nds

Type-erased NDS handle.

Wraps any concrete backend satisfying Intf.NORMAL into a single existential type so that callers can work with NDS generically. Backend-specific invalid-argument errors are normalised to Nds_errors.invalid_argument_error via a converter supplied at wrap time.

type t

Opaque NDS handle that erases the concrete backend type.

val wrap : (module Intf.NORMAL with type Registry.invalid_argument_error = 'e and type Registry.t = 'a) -> 'a -> ('e -> Nds_errors.invalid_argument_error) -> t

wrap impl value to_error packages a concrete NDS backend impl and its state value into an opaque t handle, together with a to_error function that normalises backend-specific errors to the canonical Nds_errors.invalid_argument_error closed enum.

Dispatchers

Each function below unpacks the existential, delegates to the wrapped backend, and normalises the backend error via the stored to_error converter.

val size : t -> (int64, Nds_errors.invalid_argument_error) Stdlib.result

size t returns the number of databases in the registry.

val resize : t -> int64 -> (unit, Nds_errors.invalid_argument_error) Stdlib.result

resize t n adjusts the registry to contain exactly n databases.

val copy_database : t -> src:int64 -> dst:int64 -> (unit, Nds_errors.invalid_argument_error) Stdlib.result

copy_database t ~src ~dst duplicates database src to dst.

val move_database : t -> src:int64 -> dst:int64 -> (unit, Nds_errors.invalid_argument_error) Stdlib.result

move_database t ~src ~dst moves database src to dst.

val clear : t -> int64 -> (unit, Nds_errors.invalid_argument_error) Stdlib.result

clear t db_index removes all entries from database db_index.

val registry_hash : t -> (bytes, Nds_errors.invalid_argument_error) Stdlib.result

registry_hash t returns the Merkle root hash of the registry.

val exists : t -> db_index:int64 -> key:bytes -> (bool, Nds_errors.invalid_argument_error) Stdlib.result

exists t ~db_index ~key checks whether key exists in database db_index.

val read : t -> db_index:int64 -> key:bytes -> offset:int64 -> len:int64 -> (bytes, Nds_errors.invalid_argument_error) Stdlib.result

read t ~db_index ~key ~offset ~len reads bytes from database db_index.

val write : t -> db_index:int64 -> key:bytes -> offset:int64 -> value:bytes -> (int64, Nds_errors.invalid_argument_error) Stdlib.result

write t ~db_index ~key ~offset ~value writes value starting at offset into the value associated with key in database db_index. Returns the number of bytes written (i.e. Bytes.length value).

val set : t -> db_index:int64 -> key:bytes -> value:bytes -> (unit, Nds_errors.invalid_argument_error) Stdlib.result

set t ~db_index ~key ~value replaces the value of key in database db_index.

val delete : t -> db_index:int64 -> key:bytes -> (unit, Nds_errors.invalid_argument_error) Stdlib.result

delete t ~db_index ~key removes key from database db_index.

val value_length : t -> db_index:int64 -> key:bytes -> (int64, Nds_errors.invalid_argument_error) Stdlib.result

value_length t ~db_index ~key returns the length of the value for key in database db_index.

val hash : t -> db_index:int64 -> (bytes, Nds_errors.invalid_argument_error) Stdlib.result

hash t ~db_index returns the Merkle root hash of database db_index.