wedb_embed/api/hash/
mod.rs1pub mod r#const;
2pub mod hfe;
3pub mod r#impl;
4pub mod key;
5pub mod meta;
6pub mod num;
7pub mod opt;
8pub mod query;
9pub mod scan;
10
11pub use r#const::{
12 ERR_HASH_FIELD_EXPIRATION_LEGACY_ENCODING, ERR_HASH_VALUE_NOT_FLOAT, ERR_HASH_VALUE_NOT_INTEGER,
13 ERR_INCREMENT_NAN_OR_INFINITY, ERR_INCREMENT_OVERFLOW, ERR_WRONG_TYPE, HASH_EXPIRE_COND_FAILED,
14 HASH_EXPIRE_DELETED, HASH_EXPIRE_SET_OK, HASH_FIELD_NOT_FOUND, HASH_FIELD_PERSISTENT,
15};
16pub use r#impl::prepare_hash_meta_for_write;
17pub use meta::{
18 FIELD_EXPIRE_PREFIX_LEN, HashFieldState, HashFieldStateKind, HashItemKeyComposer, HashMeta,
19 HashSubkeyEncodingMode, compose_hash_key, compose_hash_meta_key, compose_hash_prefix,
20 compose_hash_prefix_stack, decode_field_state, decode_hash_value, decode_live_hash_value,
21 encode_hash_value, encode_hash_value_into, hexpire_condition_passes, is_field_expired,
22 is_immediate_expire,
23};
24pub use opt::{
25 FieldValue, HExpire, HGetEx, HSet, HashFieldSetCondition, HashGetEx, HashLengthMode, HashSetEx,
26 RangeLex, TTLAction,
27};
28pub type HashFieldPair = (Vec<u8>, Vec<u8>);
29pub type HashRandField = (Vec<u8>, Option<Vec<u8>>);
30pub type HashScanResult = (usize, Vec<HashFieldPair>);
31pub type HashScanByFieldResult = (Option<Vec<u8>>, Vec<HashFieldPair>);
32
33use crate::{
34 error::Result,
35 meta::{parse_redis_float, parse_redis_integer},
36};
37
38#[inline(always)]
41pub(crate) const fn ceil_div_1000(val: u64) -> u64 {
42 val.div_ceil(1000)
43}
44
45#[inline]
48pub(crate) fn parse_hash_integer(v: &[u8]) -> Result<i64> {
49 parse_redis_integer(v, ERR_HASH_VALUE_NOT_INTEGER)
50}
51
52#[inline]
55pub(crate) fn parse_hash_float(v: &[u8]) -> Result<f64> {
56 parse_redis_float(v, ERR_HASH_VALUE_NOT_FLOAT)
57}
58
59#[derive(Clone)]
62pub(crate) struct CachedFieldState {
63 pub kind: HashFieldStateKind,
64 pub expire: u64,
65 pub raw: Option<Box<[u8]>>,
66}