wedb_embed 0.1.2

Embedded database engine providing Redis-like APIs, built on fjall / 嵌入式数据库引擎,提供类似 Redis 的接口,底层基于 fjall 开发
Documentation
// ================= 错误常量定义(对标 Apache Kvrocks / RedisJSON) =================

pub const ERR_NEW_OBJECTS_MUST_BE_CREATED_AT_ROOT: &str = "new objects must be created at the root";
pub const ERR_INPUT_SHOULD_BE_NUMBER: &str = "the input value should be a number";
pub const ERR_RESULT_IS_INFINITE: &str = "the result is an infinite number";
pub const ERR_STRAPPEND_NEED_STRING: &str = "STRAPPEND need input a string to append";
pub const ERR_JSON_STORAGE_FORMAT_NOT_SUPPORTED: &str = "JSON storage format not supported";
pub const ERR_CORRUPTED_JSON: &str = "ERR corrupted JSON";
pub const ERR_INVALID_JSON: &str = "ERR invalid JSON";
pub const ERR_INVALID_JSON_VALUE: &str = "ERR invalid JSON value";
pub const ERR_INVALID_JSON_NEEDLE: &str = "ERR invalid JSON needle";
pub const ERR_INVALID_JSON_PATCH: &str = "ERR invalid JSON patch";
pub const ERR_PARENT_PATH_DOES_NOT_EXIST: &str =
  "Target path does not exist and parent cannot be found";
pub const ERR_TARGET_PARENT_NOT_OBJECT: &str = "Target parent is not a JSON object to insert into";
pub const ERR_ONLY_ALL_SPACE_INDENT_SUPPORTED: &str =
  "Currently only all-space INDENT is supported";
pub const ERR_ONLY_SPACE_SUPPORTED: &str = "Currently only SPACE ' ' is supported";

/// JSON 根路径常量
pub const JSON_ROOT_PATH: &str = "$";

/// JSON 默认最大嵌套深度(对标 Kvrocks default_max_nesting_depth = 1024)
pub const DEFAULT_MAX_NESTING_DEPTH: usize = 1024;

/// JSON.SET 命令条件选项(对标 Apache Kvrocks / RedisJSON)
#[derive(Debug, Clone, Copy, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub enum JsonSet {
  /// 仅在键不存在时写入
  Nx,
  /// 仅在键已存在时覆盖写入
  Xx,
}

/// JSON.ARRINDEX 命令区间选项
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, bitcode::Encode, bitcode::Decode)]
pub struct JsonArrIndex {
  /// 起始索引(支持负数)
  pub start: isize,
  /// 终止索引(可选,支持负数)
  pub stop: Option<isize>,
}

/// JSON 数值运算类型(对标 Kvrocks NumOpEnum)
#[derive(Debug, Clone, Copy, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub enum JsonNumberOp {
  /// 数值累加 (Incr)
  Incr,
  /// 数值累乘 (Mul)
  Mul,
}

/// JSON.GET 格式化选项(对标 Apache Kvrocks INDENT / NEWLINE / SPACE 选项)
#[derive(Debug, Clone, PartialEq, Eq, Default, bitcode::Encode, bitcode::Decode)]
pub struct JsonGetOptions {
  /// 缩进字符串(如空格)
  pub indent: Option<String>,
  /// 换行符(如 "\n")
  pub newline: Option<String>,
  /// 冒号后空格(如 " ")
  pub space: Option<String>,
}