Api

Trait Api 

Source
pub trait Api<M, S>
where M: Borrow<Self::K>, S: Score,
{ type K: Key; // Required methods fn add(&self, member: impl Into<ArcM<Self::K, M>>, score: S) -> bool; fn rm(&self, member: impl Borrow<Self::K>) -> bool; fn rm_range_by_rank(&self, range: impl RangeBounds<usize>) -> usize; fn score(&self, member: impl Borrow<Self::K>) -> Option<S>; fn rank(&self, member: impl Borrow<Self::K>) -> Option<usize>; fn len(&self) -> usize; fn is_empty(&self) -> bool; fn range(&self, range: impl RangeBounds<usize>) -> Vec<ArcM<Self::K, M>>; fn range_with_scores( &self, range: impl RangeBounds<usize>, ) -> Vec<(ArcM<Self::K, M>, S)>; fn get(&self, rank: usize) -> Option<ArcM<Self::K, M>>; fn get_with_score(&self, rank: usize) -> Option<(ArcM<Self::K, M>, S)>; // Provided method fn card(&self) -> usize { ... } }
Expand description

The public API for the Zset. Zset 的公共 API。

Required Associated Types§

Source

type K: Key

Required Methods§

Source

fn add(&self, member: impl Into<ArcM<Self::K, M>>, score: S) -> bool

Adds the specified member with the specified score to the sorted set. If the member is already a member of the sorted set, the score is updated. Returns true if the score was updated, false if a new member was added. 将指定的成员和分数添加到排序集合中。 如果成员已经是排序集合的成员,则更新其分数。 如果分数被更新,则返回 true;如果是新成员,则返回 false

Source

fn rm(&self, member: impl Borrow<Self::K>) -> bool

Removes the specified member from the sorted set. 从排序集合中移除指定的成员。

Source

fn rm_range_by_rank(&self, range: impl RangeBounds<usize>) -> usize

Removes a range of members in the sorted set, with scores ordered from low to high. The range is a 0-based. Returns the number of members removed. 按排名(0-based)从低到高,删除排序集合中指定范围的成员。 返回被删除的成员数量。

Source

fn score(&self, member: impl Borrow<Self::K>) -> Option<S>

Returns the score of the specified member. 返回指定成员的分数。

Source

fn rank(&self, member: impl Borrow<Self::K>) -> Option<usize>

Returns the 0-based rank of the member in the sorted set, with scores ordered from low to high. 返回成员在排序集合中的排名(0-based),分数从低到高排序。

Source

fn len(&self) -> usize

Returns the number of elements in the sorted set (leninality). 返回排序集合中的元素数量(基数)。

Source

fn is_empty(&self) -> bool

Returns true if the sorted set contains no elements. 如果排序集合为空,则返回 true

Source

fn range(&self, range: impl RangeBounds<usize>) -> Vec<ArcM<Self::K, M>>

Returns a range of members in the sorted set, with scores ordered from low to high. The range is a 0-based, half-open interval (start..end). 返回排序集合中指定范围的成员,分数从低到高排序。 range 是一个 0-based 的半开区间 (start..end)。

Source

fn range_with_scores( &self, range: impl RangeBounds<usize>, ) -> Vec<(ArcM<Self::K, M>, S)>

Returns a range of members with their scores in the sorted set, with scores ordered from low to high. The range is a 0-based, half-open interval (start..end). 返回排序集合中指定范围的成员及其分数,分数从低到高排序。 range 是一个 0-based 的半开区间 (start..end)。

Source

fn get(&self, rank: usize) -> Option<ArcM<Self::K, M>>

Returns the member at the specified 0-based rank, with scores ordered from low to high. 返回指定排名(0-based)的成员,分数从低到高排序。

Source

fn get_with_score(&self, rank: usize) -> Option<(ArcM<Self::K, M>, S)>

Returns the member and score at the specified 0-based rank, with scores ordered from low to high. 返回指定排名(0-based)的成员和分数,分数从低到高排序。

Provided Methods§

Source

fn card(&self) -> usize

Returns the number of elements in the sorted set. This is an alias for len(). 返回排序集合中的元素数量。这是 len() 的别名。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<K, M, S> Api<M, S> for Zset<K, M, S>
where K: Key, M: Member<K>, S: Score,

Source§

type K = K