Struct Set

Source
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>

Source

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.

Source

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.

Source

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.

Source

pub async fn exist(&self, value: &T) -> Result<bool, ErrorTypes>

Check if an item is in the set

Source

pub async fn length(&self) -> Result<u64, ErrorTypes>

Read the number of items in the set

Source

pub async fn members(&self) -> Result<Vec<T>, ErrorTypes>

Read the entire content of the set

Source

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.

Source

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.

Source

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.

Source

pub async fn random(&self) -> Result<Option<T>, ErrorTypes>

Remove and return a random item from the set.

Source

pub async fn pop(&self) -> Result<Option<T>, ErrorTypes>

Remove and return a single value from the set.

Source

pub async fn pop_all(&self) -> Result<Vec<T>, ErrorTypes>

Remove and return all values from the set.

Source

pub async fn delete(&self) -> Result<(), ErrorTypes>

Remove and drop all values from the set.

Auto Trait Implementations§

§

impl<T> !Freeze for Set<T>

§

impl<T> !RefUnwindSafe for Set<T>

§

impl<T> Send for Set<T>
where T: Send,

§

impl<T> Sync for Set<T>
where T: Sync,

§

impl<T> Unpin for Set<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Set<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,