mod_redis

Trait FromRedisValue

pub trait FromRedisValue: Sized {
    // Required method
    fn from_redis_value(v: &Value) -> Result<Self, RedisError>;

    // Provided methods
    fn from_owned_redis_value(v: Value) -> Result<Self, RedisError> { ... }
    fn from_redis_values(items: &[Value]) -> Result<Vec<Self>, RedisError> { ... }
    fn from_owned_redis_values(
        items: Vec<Value>,
    ) -> Result<Vec<Self>, RedisError> { ... }
    fn from_byte_vec(_vec: &[u8]) -> Option<Vec<Self>> { ... }
    fn from_owned_byte_vec(_vec: Vec<u8>) -> Result<Vec<Self>, RedisError> { ... }
}
Expand description

This trait is used to convert a redis value into a more appropriate type.

While a redis Value can represent any response that comes back from the redis server, usually you want to map this into something that works better in rust. For instance you might want to convert the return value into a String or an integer.

This trait is well supported throughout the library and you can implement it for your own types if you want.

In addition to what you can see from the docs, this is also implemented for tuples up to size 12 and for Vec<u8>.

Required Methods§

fn from_redis_value(v: &Value) -> Result<Self, RedisError>

Given a redis Value this attempts to convert it into the given destination type. If that fails because it’s not compatible an appropriate error is generated.

Provided Methods§

fn from_owned_redis_value(v: Value) -> Result<Self, RedisError>

Given a redis Value this attempts to convert it into the given destination type. If that fails because it’s not compatible an appropriate error is generated.

fn from_redis_values(items: &[Value]) -> Result<Vec<Self>, RedisError>

Similar to from_redis_value but constructs a vector of objects from another vector of values. This primarily exists internally to customize the behavior for vectors of tuples.

fn from_owned_redis_values(items: Vec<Value>) -> Result<Vec<Self>, RedisError>

The same as from_redis_values, but takes a Vec<Value> instead of a &[Value].

fn from_byte_vec(_vec: &[u8]) -> Option<Vec<Self>>

Convert bytes to a single element vector.

fn from_owned_byte_vec(_vec: Vec<u8>) -> Result<Vec<Self>, RedisError>

Convert bytes to a single element vector.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl FromRedisValue for bool

§

impl FromRedisValue for f32

§

impl FromRedisValue for f64

§

impl FromRedisValue for i8

§

impl FromRedisValue for i16

§

impl FromRedisValue for i32

§

impl FromRedisValue for i64

§

impl FromRedisValue for i128

§

impl FromRedisValue for isize

§

impl FromRedisValue for u8

§

impl FromRedisValue for u16

§

impl FromRedisValue for u32

§

impl FromRedisValue for u64

§

impl FromRedisValue for u128

§

impl FromRedisValue for ()

§

impl FromRedisValue for usize

§

impl FromRedisValue for CString

§

impl FromRedisValue for String

§

impl FromRedisValue for Bytes

§

impl<K, V> FromRedisValue for BTreeMap<K, V>

§

impl<K, V, S> FromRedisValue for HashMap<K, V, S>

§

impl<T> FromRedisValue for Option<T>
where T: FromRedisValue,

§

impl<T> FromRedisValue for Box<[T]>
where T: FromRedisValue,

§

impl<T> FromRedisValue for Box<T>
where T: FromRedisValue,

§

impl<T> FromRedisValue for BTreeSet<T>
where T: FromRedisValue + Eq + Ord,

§

impl<T> FromRedisValue for Rc<T>
where T: FromRedisValue,

§

impl<T> FromRedisValue for Arc<[T]>
where T: FromRedisValue,

§

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

§

impl<T> FromRedisValue for Vec<T>
where T: FromRedisValue,

§

impl<T, S> FromRedisValue for HashSet<T, S>

§

impl<T, const N: usize> FromRedisValue for [T; N]
where T: FromRedisValue,

Implementors§

§

impl FromRedisValue for Value

§

impl FromRedisValue for AclInfo

§

impl FromRedisValue for InfoDict

§

impl FromRedisValue for RadiusSearchResult

§

impl FromRedisValue for ReplicaInfo

§

impl FromRedisValue for Role

§

impl FromRedisValue for StreamAutoClaimReply

§

impl FromRedisValue for StreamClaimReply

§

impl FromRedisValue for StreamInfoConsumersReply

§

impl FromRedisValue for StreamInfoGroupsReply

§

impl FromRedisValue for StreamInfoStreamReply

§

impl FromRedisValue for StreamPendingCountReply

§

impl FromRedisValue for StreamPendingReply

§

impl FromRedisValue for StreamRangeReply

§

impl FromRedisValue for StreamReadReply

§

impl<T> FromRedisValue for Coord<T>
where T: FromRedisValue,