redis

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§

impl ToRedisArgs for f64

Source§

impl ToRedisArgs for i8

Source§

impl ToRedisArgs for i16

Source§

impl ToRedisArgs for i32

Source§

impl ToRedisArgs for i64

Source§

impl ToRedisArgs for isize

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§

impl ToRedisArgs for u32

Source§

impl ToRedisArgs for u64

Source§

impl ToRedisArgs for usize

Source§

impl ToRedisArgs for String

Source§

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

Source§

impl ToRedisArgs for NonZeroI8

Source§

impl ToRedisArgs for NonZeroI16

Source§

impl ToRedisArgs for NonZeroI32

Source§

impl ToRedisArgs for NonZeroI64

Source§

impl ToRedisArgs for NonZeroIsize

Source§

impl ToRedisArgs for NonZeroU8

Source§

impl ToRedisArgs for NonZeroU16

Source§

impl ToRedisArgs for NonZeroU32

Source§

impl ToRedisArgs for NonZeroU64

Source§

impl ToRedisArgs for NonZeroUsize

Source§

impl<'a, T> ToRedisArgs for Cow<'a, T>
where T: ToOwned + ?Sized, &'a T: ToRedisArgs, for<'b> &'b 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§

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

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> ToRedisArgs for HashMap<K, V>
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 Box<T>
where T: ToRedisArgs,

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> ToRedisArgs for Rc<T>
where T: ToRedisArgs,

Source§

impl<T> ToRedisArgs for Arc<T>
where T: ToRedisArgs,

Source§

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

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 &[T]

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§

impl<T: ToRedisArgs> ToRedisArgs for Vec<T>

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§