import { AsyncVoidIOResult, VoidIOResult, AsyncIOResult, IOResult } from 'happy-rusty';

/**
 * 本地存储模块，提供同步和异步的键值对存储功能。
 * @module storage
 */

/**
 * 将数据存储在本地缓存中。
 * @param key - 数据的键名。
 * @param data - 要存储的数据。
 * @returns 存储操作的异步结果。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = await setItem('username', 'john');
 * if (result.isOk()) {
 *     console.log('存储成功');
 * }
 * ```
 */
declare function setItem(key: string, data: string): AsyncVoidIOResult;
/**
 * 从本地缓存中读取数据。
 * @param key - 数据的键名。
 * @returns 包含数据的异步结果，如果不存在则返回空字符串。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = await getItem('username');
 * if (result.isOk()) {
 *     console.log('用户名:', result.unwrap());
 * }
 * ```
 */
declare function getItem(key: string): AsyncIOResult<string>;
/**
 * 从本地缓存中移除指定的数据。
 * @param key - 数据的键名。
 * @returns 移除操作的异步结果。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = await removeItem('username');
 * if (result.isOk()) {
 *     console.log('移除成功');
 * }
 * ```
 */
declare function removeItem(key: string): AsyncVoidIOResult;
/**
 * 清除所有的本地存储数据。
 * @returns 清除操作的异步结果。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = await clear();
 * if (result.isOk()) {
 *     console.log('所有数据已清除');
 * }
 * ```
 */
declare function clear(): AsyncVoidIOResult;
/**
 * 获取本地存储数据的项数。
 * @returns 包含存储项数的异步结果。
 * @since 1.2.0
 * @example
 * ```ts
 * const result = await getLength();
 * if (result.isOk()) {
 *     console.log('存储项数:', result.unwrap());
 * }
 * ```
 */
declare function getLength(): AsyncIOResult<number>;
/**
 * 检查本地存储中是否存在指定的数据。
 * @param key - 数据的键名。
 * @returns 包含是否存在的布尔值的异步结果。
 * @since 1.9.3
 * @example
 * ```ts
 * const result = await hasItem('username');
 * if (result.isOk() && result.unwrap()) {
 *     console.log('键存在');
 * }
 * ```
 */
declare function hasItem(key: string): AsyncIOResult<boolean>;
/**
 * `setItem` 的同步版本，将数据存储在本地缓存中。
 * @param key - 数据的键名。
 * @param data - 要存储的数据。
 * @returns 存储操作的结果。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = setItemSync('username', 'john');
 * if (result.isOk()) {
 *     console.log('存储成功');
 * }
 * ```
 */
declare function setItemSync(key: string, data: string): VoidIOResult;
/**
 * `getItem` 的同步版本，从本地缓存中读取数据。
 * @param key - 数据的键名。
 * @returns 包含数据的操作结果。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = getItemSync('username');
 * if (result.isOk()) {
 *     console.log('用户名:', result.unwrap());
 * }
 * ```
 */
declare function getItemSync(key: string): IOResult<string>;
/**
 * `removeItem` 的同步版本，从本地缓存中移除指定的数据。
 * @param key - 数据的键名。
 * @returns 移除操作的结果。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = removeItemSync('username');
 * if (result.isOk()) {
 *     console.log('移除成功');
 * }
 * ```
 */
declare function removeItemSync(key: string): VoidIOResult;
/**
 * `clear` 的同步版本，清除所有的本地存储数据。
 * @returns 清除操作的结果。
 * @since 1.0.0
 * @example
 * ```ts
 * const result = clearSync();
 * if (result.isOk()) {
 *     console.log('所有数据已清除');
 * }
 * ```
 */
declare function clearSync(): VoidIOResult;
/**
 * `getLength` 的同步版本，获取本地存储数据的项数。
 * @returns 包含存储项数的操作结果。
 * @since 1.2.0
 * @example
 * ```ts
 * const result = getLengthSync();
 * if (result.isOk()) {
 *     console.log('存储项数:', result.unwrap());
 * }
 * ```
 */
declare function getLengthSync(): IOResult<number>;
/**
 * `hasItem` 的同步版本，检查本地存储中是否存在指定的数据。
 * @param key - 数据的键名。
 * @returns 包含是否存在的布尔值的操作结果。
 * @since 1.9.3
 * @example
 * ```ts
 * const result = hasItemSync('username');
 * if (result.isOk() && result.unwrap()) {
 *     console.log('键存在');
 * }
 * ```
 */
declare function hasItemSync(key: string): IOResult<boolean>;

export { clear, clearSync, getItem, getItemSync, getLength, getLengthSync, hasItem, hasItemSync, removeItem, removeItemSync, setItem, setItemSync };
