ValueComparison

Enum ValueComparison 

Source
#[non_exhaustive]
pub enum ValueComparison { IFEQ(String), IFNE(String), IFDEQ(String), IFDNE(String), }
Expand description

Helper enum that is used to define comparisons between values and their digests

§Example

use redis::ValueComparison;

// Create comparisons using constructor methods
let eq_comparison = ValueComparison::ifeq("my_value");
let ne_comparison = ValueComparison::ifne("other_value");
let deq_comparison = ValueComparison::ifdeq("digest_hash");
let dne_comparison = ValueComparison::ifdne("other_digest");

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

IFEQ(String)

Value is equal

§

IFNE(String)

Value is not equal

§

IFDEQ(String)

Value’s digest is equal

§

IFDNE(String)

Value’s digest is not equal

Implementations§

Source§

impl ValueComparison

Source

pub fn ifeq(value: impl ToSingleRedisArg) -> Self

Create a new IFEQ (if equal) comparison

Performs the operation only if the key’s current value is equal to the provided value.

For SET: Sets the key only if its current value matches. Non-existent keys are not created. For DEL_EX: Deletes the key only if its current value matches. Non-existent keys are ignored.

Source

pub fn ifne(value: impl ToSingleRedisArg) -> Self

Create a new IFNE (if not equal) comparison

Performs the operation only if the key’s current value is not equal to the provided value.

For SET: Sets the key only if its current value doesn’t match. Non-existent keys are created. For DEL_EX: Deletes the key only if its current value doesn’t match. Non-existent keys are ignored.

Source

pub fn ifdeq(digest: impl ToSingleRedisArg) -> Self

Create a new IFDEQ (if digest equal) comparison

Performs the operation only if the digest of the key’s current value is equal to the provided digest.

For SET: Sets the key only if its current value’s digest matches. Non-existent keys are not created. For DEL_EX: Deletes the key only if its current value’s digest matches. Non-existent keys are ignored.

Use calculate_value_digest to compute the digest of a value.

Source

pub fn ifdne(digest: impl ToSingleRedisArg) -> Self

Create a new IFDNE (if digest not equal) comparison

Performs the operation only if the digest of the key’s current value is not equal to the provided digest.

For SET: Sets the key only if its current value’s digest doesn’t match. Non-existent keys are created. For DEL_EX: Deletes the key only if its current value’s digest doesn’t match. Non-existent keys are ignored.

Use calculate_value_digest to compute the digest of a value.

Trait Implementations§

Source§

impl Clone for ValueComparison

Source§

fn clone(&self) -> ValueComparison

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValueComparison

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ToRedisArgs for ValueComparison

Source§

fn write_redis_args<W>(&self, out: &mut W)
where W: ?Sized + RedisWrite,

This writes the value into a vector of bytes. Each item is a single argument. Most items generate a single item. Read more
Source§

fn to_redis_args(&self) -> Vec<Vec<u8>>

This converts the value into a vector of bytes. Each item is a single argument. Most items generate a vector of a single item. Read more
Source§

fn describe_numeric_behavior(&self) -> NumericBehavior

Returns an information about the contained value with regards to it’s numeric behavior in a redis context. This is used in some high level concepts to switch between different implementations of redis functions (for instance INCR vs INCRBYFLOAT).
Source§

fn num_of_args(&self) -> usize

Returns the number of arguments this value will generate. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> ErasedDestructor for T
where T: 'static,