ToRedisArgs in redis - Rust
Description: Used to convert a value into one or multiple redis argument strings. Most values will produce exactly one item but in some cases it might make sense to produce more than one.

Skip to main content

## ToRedisArgs

# Trait ToRedisArgs

Source

    pub trait ToRedisArgs: Sized {
        // Required method
        fn write_redis_args<W>(&self, out: &mut W)
           where W: ?Sized + RedisWrite;

        // Provided methods
        fn to_redis_args(&self) -> Vec<Vec<u8>> { ... }
        fn describe_numeric_behavior(&self) -> NumericBehavior { ... }
        fn num_of_args(&self) -> usize { ... }
    }

Expand description

Used to convert a value into one or multiple redis argument strings. Most values will produce exactly one item but in some cases it might make sense to produce more than one.

## Required Methods§

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.

The exception to this rule currently are vectors of items.

## Provided Methods§

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.

The exception to this rule currently are vectors of items.

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.

This is used in some high level functions to intelligently switch between `GET` and `MGET` variants. Also, for some commands like HEXPIREDAT which require a specific number of arguments, this method can be used to know the number of arguments.

## 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.

## Implementations on Foreign Types§

Source§

### impl ToRedisArgs for &str

Source§

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

Source§

### impl ToRedisArgs for bool

Source§

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

Source§

### impl ToRedisArgs for f32

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for f64

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for i8

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for i16

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for i32

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for i64

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for i128

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for isize

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for u8

Source§

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

Source§

### impl ToRedisArgs for u16

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for u32

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for u64

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for u128

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for usize

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for String

Source§

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

Source§

### impl ToRedisArgs for BigInt

Source§

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

Source§

### impl ToRedisArgs for BigUint

Source§

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

Source§

### impl ToRedisArgs for Uuid

Available on crate feature `uuid` only.
Source§

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

Source§

### impl ToRedisArgs for NonZeroI8

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroI16

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroI32

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroI64

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroI128

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroIsize

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroU8

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroU16

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroU32

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroU64

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroU128

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for NonZeroUsize

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl ToRedisArgs for BigDecimal

Source§

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

Source§

### impl ToRedisArgs for Decimal

Source§

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

Source§

### impl<'a, T> ToRedisArgs for &'a [T]
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for &'a mut [T]
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Cow<'a, T>
where T: ToOwned + ?Sized, &'a T: ToRedisArgs, T::Owned: ToRedisArgs,

Source§

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

Source§

### impl<'a, T> ToRedisArgs for &'a T
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for &'a mut T
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Box<[T]>
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Box<T>
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Rc<[T]>
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Rc<T>
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Arc<[T]>
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Arc<T>
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<'a, T> ToRedisArgs for Vec<T>
where T: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

### impl<K, V> ToRedisArgs for BTreeMap<K, V>
where K: ToRedisArgs + Hash + Eq + Ord, V: ToRedisArgs,

this flattens BTreeMap into something that goes well with HMSET

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<K, V, S> ToRedisArgs for HashMap<K, V, S>
where K: ToRedisArgs + Hash + Eq + Ord, V: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<K, V, S> ToRedisArgs for AHashMap<K, V, S>
where K: ToRedisArgs + Hash + Eq + Ord, V: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<K, V, S> ToRedisArgs for HashMap<K, V, S>
where K: ToRedisArgs + Hash + Eq + Ord, V: ToRedisArgs,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<T> ToRedisArgs for BTreeSet<T>
where T: ToRedisArgs + Hash + Eq + Ord,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<T, S> ToRedisArgs for HashSet<T, S>
where T: ToRedisArgs + Hash + Eq,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<T, S> ToRedisArgs for AHashSet<T, S>
where T: ToRedisArgs + Hash + Eq,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<T, S> ToRedisArgs for HashSet<T, S>
where T: ToRedisArgs + Hash + Eq,

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<T: ToRedisArgs> ToRedisArgs for Option<T>

Source§

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

Source§

#### fn describe_numeric_behavior(&self) -> NumericBehavior

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<T: ToRedisArgs> ToRedisArgs for (T₁, T₂, …, Tₙ)

This trait is implemented for tuples up to 12 items long.

Source§

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

Source§

#### fn num_of_args(&self) -> usize

Source§

### impl<T: ToRedisArgs, const N: usize> ToRedisArgs for &[T; N]

Source§

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

Source§

#### fn num_of_args(&self) -> usize

## Implementors§

Source§

### impl ToRedisArgs for Rule

Available on crate feature `acl` only.
Source§

### impl ToRedisArgs for Direction

Source§

### impl ToRedisArgs for ExistenceCheck

Source§

### impl ToRedisArgs for ExpireOption

Source§

### impl ToRedisArgs for Expiry

Source§

### impl ToRedisArgs for FieldExistenceCheck

Source§

### impl ToRedisArgs for SetExpiry

Source§

### impl ToRedisArgs for UpdateCheck

Source§

### impl ToRedisArgs for ValueComparison

Source§

### impl ToRedisArgs for Unit

Available on crate feature `geospatial` only.
Source§

### impl ToRedisArgs for StreamDeletionPolicy

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for StreamMaxlen

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for StreamTrimStrategy

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for StreamTrimmingMode

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for EmbeddingInput<'_>

Available on crate feature `vector-sets` only.
Source§

### impl ToRedisArgs for VectorAddInput<'_>

Available on crate feature `vector-sets` only.
Source§

### impl ToRedisArgs for VectorSimilaritySearchInput<'_>

Available on crate feature `vector-sets` only.
Source§

### impl ToRedisArgs for RadiusOptions

Available on crate feature `geospatial` only.
Source§

### impl ToRedisArgs for StreamAddOptions

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for StreamAutoClaimOptions

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for StreamClaimOptions

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for StreamReadOptions

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for StreamTrimOptions

Available on crate feature `streams` only.
Source§

### impl ToRedisArgs for FlushAllOptions

Source§

### impl ToRedisArgs for HashFieldExpirationOptions

Source§

### impl ToRedisArgs for LposOptions

Source§

### impl ToRedisArgs for MSetOptions

Source§

### impl ToRedisArgs for ScanOptions

Source§

### impl ToRedisArgs for SetOptions

Source§

### impl ToRedisArgs for SortedSetAddOptions

Source§

### impl ToRedisArgs for VAddOptions

Available on crate feature `vector-sets` only.
Source§

### impl ToRedisArgs for VEmbOptions

Available on crate feature `vector-sets` only.
Source§

### impl ToRedisArgs for VSimOptions

Available on crate feature `vector-sets` only.
Source§

### impl<Db: ToString> ToRedisArgs for CopyOptions<Db>

Source§

### impl<T: ToRedisArgs> ToRedisArgs for Coord<T>

Available on crate feature `geospatial` only.