pub mod r#const;
pub mod hfe;
pub mod r#impl;
pub mod key;
pub mod meta;
pub mod num;
pub mod opt;
pub mod query;
pub mod scan;
pub use r#const::{
ERR_HASH_FIELD_EXPIRATION_LEGACY_ENCODING, ERR_HASH_VALUE_NOT_FLOAT, ERR_HASH_VALUE_NOT_INTEGER,
ERR_INCREMENT_NAN_OR_INFINITY, ERR_INCREMENT_OVERFLOW, ERR_WRONG_TYPE, HASH_EXPIRE_COND_FAILED,
HASH_EXPIRE_DELETED, HASH_EXPIRE_SET_OK, HASH_FIELD_NOT_FOUND, HASH_FIELD_PERSISTENT,
};
pub use r#impl::prepare_hash_meta_for_write;
pub use meta::{
FIELD_EXPIRE_PREFIX_LEN, HashFieldState, HashFieldStateKind, HashItemKeyComposer, HashMeta,
HashSubkeyEncodingMode, compose_hash_key, compose_hash_meta_key, compose_hash_prefix,
compose_hash_prefix_stack, decode_field_state, decode_hash_value, decode_live_hash_value,
encode_hash_value, encode_hash_value_into, hexpire_condition_passes, is_field_expired,
is_immediate_expire,
};
pub use opt::{
FieldValue, HExpire, HGetEx, HSet, HashFieldSetCondition, HashGetEx, HashLengthMode, HashSetEx,
RangeLex, TTLAction,
};
pub type HashFieldPair = (Vec<u8>, Vec<u8>);
pub type HashRandField = (Vec<u8>, Option<Vec<u8>>);
pub type HashScanResult = (usize, Vec<HashFieldPair>);
pub type HashScanByFieldResult = (Option<Vec<u8>>, Vec<HashFieldPair>);
use crate::{
error::Result,
meta::{parse_redis_float, parse_redis_integer},
};
#[inline(always)]
pub(crate) const fn ceil_div_1000(val: u64) -> u64 {
val.div_ceil(1000)
}
#[inline]
pub(crate) fn parse_hash_integer(v: &[u8]) -> Result<i64> {
parse_redis_integer(v, ERR_HASH_VALUE_NOT_INTEGER)
}
#[inline]
pub(crate) fn parse_hash_float(v: &[u8]) -> Result<f64> {
parse_redis_float(v, ERR_HASH_VALUE_NOT_FLOAT)
}
#[derive(Clone)]
pub(crate) struct CachedFieldState {
pub kind: HashFieldStateKind,
pub expire: u64,
pub raw: Option<Box<[u8]>>,
}