import type { Key, Range, Value } from './common.js'; /** * A map backed by a persistent store. */ interface AztecBaseMap { /** * Sets the value at the given key. * @param key - The key to set the value at * @param val - The value to set */ set(key: K, val: V): Promise; /** * Sets the values at the given keys. * @param entries - The entries to set */ setMany(entries: { key: K; value: V }[]): Promise; /** * Sets the value at the given key if it does not already exist. * @param key - The key to set the value at * @param val - The value to set */ setIfNotExists(key: K, val: V): Promise; /** * Deletes the value at the given key. * @param key - The key to delete the value at */ delete(key: K): Promise; } export interface AztecMap extends AztecBaseMap { /** * Gets the value at the given key. * @param key - The key to get the value from */ get(key: K): V | undefined; /** * Gets the current size of the map. * @returns The size of the map */ size(): number; /** * Checks if a key exists in the map. * @param key - The key to check * @returns True if the key exists, false otherwise */ has(key: K): boolean; /** * Iterates over the map's key-value entries in the key's natural order * @param range - The range of keys to iterate over */ entries(range?: Range): IterableIterator<[K, V]>; /** * Iterates over the map's values in the key's natural order * @param range - The range of keys to iterate over */ values(range?: Range): IterableIterator; /** * Iterates over the map's keys in the key's natural order * @param range - The range of keys to iterate over */ keys(range?: Range): IterableIterator; /** * Clears the map. */ clear(): Promise; } /** * A map backed by a persistent store. */ export interface AztecAsyncMap extends AztecBaseMap { /** * Gets the value at the given key. * @param key - The key to get the value from */ getAsync(key: K): Promise; /** * Checks if a key exists in the map. * @param key - The key to check * @returns True if the key exists, false otherwise */ hasAsync(key: K): Promise; /** * Iterates over the map's key-value entries in the key's natural order * @param range - The range of keys to iterate over */ entriesAsync(range?: Range): AsyncIterableIterator<[K, V]>; /** * Iterates over the map's values in the key's natural order * @param range - The range of keys to iterate over */ valuesAsync(range?: Range): AsyncIterableIterator; /** * Iterates over the map's keys in the key's natural order * @param range - The range of keys to iterate over */ keysAsync(range?: Range): AsyncIterableIterator; /** * Gets the current size of the map. * @returns The size of the map */ sizeAsync(): Promise; }