Trait redis::FromRedisValue

source ·
pub trait FromRedisValue: Sized {
    // Required method
    fn from_redis_value(v: &Value) -> RedisResult<Self>;

    // Provided methods
    fn from_redis_values(items: &[Value]) -> RedisResult<Vec<Self>> { ... }
    fn from_byte_vec(_vec: &[u8]) -> Option<Vec<Self>> { ... }
}
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§

source

fn from_redis_value(v: &Value) -> RedisResult<Self>

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§

source

fn from_redis_values(items: &[Value]) -> RedisResult<Vec<Self>>

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.

source

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

Convert bytes to a single element vector.

Implementations on Foreign Types§

source§

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

source§

impl FromRedisValue for f32

source§

impl FromRedisValue for i128

source§

impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue, S: BuildHasher + Default> FromRedisValue for HashMap<K, V, S>

source§

impl<T: FromRedisValue + Eq + Hash, S: BuildHasher + Default> FromRedisValue for AHashSet<T, S>

source§

impl FromRedisValue for u128

source§

impl FromRedisValue for u16

source§

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

source§

impl FromRedisValue for bool

source§

impl FromRedisValue for u64

source§

impl FromRedisValue for usize

source§

impl FromRedisValue for u8

source§

impl FromRedisValue for f64

source§

impl FromRedisValue for i16

source§

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

source§

impl FromRedisValue for u32

source§

impl FromRedisValue for Bytes

source§

impl FromRedisValue for isize

source§

impl FromRedisValue for ()

source§

impl FromRedisValue for i8

source§

impl FromRedisValue for CString

source§

impl FromRedisValue for i64

source§

impl FromRedisValue for String

source§

impl FromRedisValue for i32

source§

impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue, S: BuildHasher + Default> FromRedisValue for AHashMap<K, V, S>

source§

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

source§

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

Implementors§

source§

impl FromRedisValue for Value

source§

impl FromRedisValue for StreamPendingReply

Available on crate feature streams only.
source§

impl FromRedisValue for AclInfo

Available on crate feature acl only.
source§

impl FromRedisValue for RadiusSearchResult

Available on crate feature geospatial only.
source§

impl FromRedisValue for StreamClaimReply

Available on crate feature streams only.
source§

impl FromRedisValue for StreamInfoConsumersReply

Available on crate feature streams only.
source§

impl FromRedisValue for StreamInfoGroupsReply

Available on crate feature streams only.
source§

impl FromRedisValue for StreamInfoStreamReply

Available on crate feature streams only.
source§

impl FromRedisValue for StreamPendingCountReply

Available on crate feature streams only.
source§

impl FromRedisValue for StreamRangeReply

Available on crate feature streams only.
source§

impl FromRedisValue for StreamReadReply

Available on crate feature streams only.
source§

impl FromRedisValue for InfoDict

source§

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

Available on crate feature geospatial only.