Skip to main content

IncrexOptions

Struct IncrexOptions 

Source
pub struct IncrexOptions<T> { /* private fields */ }
Expand description

Options for the INCREX command.

T is the type of the increment and of the LBOUND/UBOUND bounds. It matches the increment passed to increx. (e.g. IncrexOptions<i64> for an i64 increment, IncrexOptions<f64> for an f64 one).

§Example

use redis::{Commands, RedisResult, IncrexOptions, IncrexResult, Expiry};
fn bump(con: &mut redis::Connection) -> RedisResult<IncrexResult> {
    let opts = IncrexOptions::default()
        .saturate()
        .upper_bound(100)
        .with_expiration(Expiry::EX(60));
    con.increx("counter", 5, opts)
}

Implementations§

Source§

impl<T: ToSingleRedisArg> IncrexOptions<T>

Source

pub fn saturate(self) -> Self

Instead of rejecting an out-of-bounds operation, clamp the result to the specified bound or to the type’s limit when no explicit bound is set.

Source

pub fn lower_bound(self, lower_bound: T) -> Self

Set the lower bound for the operation (LBOUND).

Source

pub fn upper_bound(self, upper_bound: T) -> Self

Set the upper bound for the operation (UBOUND).

Source

pub fn with_expiration(self, expiration: Expiry) -> Self

Set the expiration to apply to the key (EX/PX/EXAT/PXAT/PERSIST).

Source

pub fn enx(self) -> Self

Only apply the expiration if the key currently has no TTL (ENX).

Requires an expiration other than Expiry::PERSIST to be set. The server rejects ENX combined with PERSIST.

Trait Implementations§

Source§

impl<T: Clone> Clone for IncrexOptions<T>

Source§

fn clone(&self) -> IncrexOptions<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Default> Default for IncrexOptions<T>

Source§

fn default() -> IncrexOptions<T>

Returns the “default value” for a type. Read more
Source§

impl<T: ToRedisArgs> ToRedisArgs for IncrexOptions<T>

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§

§

impl<T> Freeze for IncrexOptions<T>
where Option<T>: Freeze,

§

impl<T> RefUnwindSafe for IncrexOptions<T>

§

impl<T> Send for IncrexOptions<T>
where Option<T>: Send,

§

impl<T> Sync for IncrexOptions<T>
where Option<T>: Sync,

§

impl<T> Unpin for IncrexOptions<T>
where Option<T>: Unpin,

§

impl<T> UnsafeUnpin for IncrexOptions<T>
where Option<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for IncrexOptions<T>
where Option<T>: UnwindSafe,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.