wedb_embed 0.1.0

Embedded Kvrocks-compatible storage engine for WeDb
Documentation
/// LPOS 选项配置(对标 Apache Kvrocks PosSpec)
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PosSpec {
    /// 匹配项序号(1 为第 1 个,-1 为倒数第 1 个,禁止为 0)
    pub rank: i64,
    /// 最多返回的匹配项数量
    pub count: Option<usize>,
    /// 最大扫描元素数(0 或 None 表示全量扫描)
    pub max_len: Option<usize>,
}

impl PosSpec {
    #[inline]
    pub const fn new() -> Self {
        Self {
            rank: 1,
            count: None,
            max_len: None,
        }
    }

    #[inline]
    pub const fn with_rank(mut self, rank: i64) -> Self {
        self.rank = rank;
        self
    }

    #[inline]
    pub const fn with_count(mut self, count: usize) -> Self {
        self.count = Some(count);
        self
    }

    #[inline]
    pub const fn with_max_len(mut self, max_len: usize) -> Self {
        self.max_len = Some(max_len);
        self
    }
}

impl Default for PosSpec {
    #[inline]
    fn default() -> Self {
        Self::new()
    }
}