pub struct Set<T> { /* private fields */ }
Expand description
A collection of unique values in a redis object
Implementations§
Source§impl<T: Serialize + DeserializeOwned> Set<T>
impl<T: Serialize + DeserializeOwned> Set<T>
Sourcepub async fn add(&self, value: &T) -> Result<bool, ErrorTypes>
pub async fn add(&self, value: &T) -> Result<bool, ErrorTypes>
Insert an item into the set. Return whether the item is new to the set.
Sourcepub async fn add_batch(&self, values: &[T]) -> Result<usize, ErrorTypes>
pub async fn add_batch(&self, values: &[T]) -> Result<usize, ErrorTypes>
Insert a batch of items to the set. Return how many items were new to the set.
Sourcepub async fn limited_add(
&self,
value: &T,
size_limit: usize,
) -> Result<bool, ErrorTypes>
pub async fn limited_add( &self, value: &T, size_limit: usize, ) -> Result<bool, ErrorTypes>
Add a single value to the set, but only if that wouldn’t make the set grow past a given size.
Sourcepub async fn exist(&self, value: &T) -> Result<bool, ErrorTypes>
pub async fn exist(&self, value: &T) -> Result<bool, ErrorTypes>
Check if an item is in the set
Sourcepub async fn length(&self) -> Result<u64, ErrorTypes>
pub async fn length(&self) -> Result<u64, ErrorTypes>
Read the number of items in the set
Sourcepub async fn members(&self) -> Result<Vec<T>, ErrorTypes>
pub async fn members(&self) -> Result<Vec<T>, ErrorTypes>
Read the entire content of the set
Sourcepub async fn remove(&self, value: &T) -> Result<bool, ErrorTypes>
pub async fn remove(&self, value: &T) -> Result<bool, ErrorTypes>
Try to remove a given value from the set and return if any change has been made.
Sourcepub async fn remove_batch(&self, values: &[T]) -> Result<usize, ErrorTypes>
pub async fn remove_batch(&self, values: &[T]) -> Result<usize, ErrorTypes>
Try to remove multiple items from the set. Return how many items were removed.
Sourcepub async fn drop(&self, value: &T) -> Result<usize, ErrorTypes>
pub async fn drop(&self, value: &T) -> Result<usize, ErrorTypes>
Remove a given value from the set and return the new size of the set.
Sourcepub async fn random(&self) -> Result<Option<T>, ErrorTypes>
pub async fn random(&self) -> Result<Option<T>, ErrorTypes>
Remove and return a random item from the set.
Sourcepub async fn pop(&self) -> Result<Option<T>, ErrorTypes>
pub async fn pop(&self) -> Result<Option<T>, ErrorTypes>
Remove and return a single value from the set.
Sourcepub async fn pop_all(&self) -> Result<Vec<T>, ErrorTypes>
pub async fn pop_all(&self) -> Result<Vec<T>, ErrorTypes>
Remove and return all values from the set.
Sourcepub async fn delete(&self) -> Result<(), ErrorTypes>
pub async fn delete(&self) -> Result<(), ErrorTypes>
Remove and drop all values from the set.