FromRedisValue in redis - Rust
Description: This trait is used to convert a redis value into a more appropriate type.

Skip to main content

## FromRedisValue

# Trait FromRedisValue

Source

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

        // Provided methods
        fn from_redis_value_ref(v: &Value) -> Result<Self, ParsingError> { ... }
        fn from_redis_value_refs(items: &[Value]) -> Result<Vec<Self>, ParsingError> { ... }
        fn from_redis_values(items: Vec<Value>) -> Result<Vec<Self>, ParsingError> { ... }
        fn from_each_redis_values(
            items: Vec<Value>,
        ) -> Vec<Result<Self, ParsingError>> { ... }
        fn from_byte_slice(_vec: &[u8]) -> Option<Vec<Self>> { ... }
        fn from_byte_vec(_vec: Vec<u8>) -> Result<Vec<Self>, ParsingError> { ... }
    }

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) -> Result<Self, ParsingError>

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_value_ref(v: &Value) -> Result<Self, ParsingError>

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.

Source

#### fn from_redis_value_refs(items: &[Value]) -> Result<Vec<Self>, ParsingError>

Similar to `from_redis_value_ref` 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_redis_values(items: Vec<Value>) -> Result<Vec<Self>, ParsingError>

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

Source

#### fn from_each_redis_values(items: Vec<Value>) -> Vec<Result<Self, ParsingError>>

The same as `from_redis_values`, but returns a result for each conversion to make handling them case-by-case possible.

Source

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

Convert bytes to a single element vector.

Source

#### fn from_byte_vec(_vec: Vec<u8>) -> Result<Vec<Self>, ParsingError>

Convert bytes to a single element vector.

## 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 FromRedisValue for bool

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<bool, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for f32

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<f32, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for f64

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<f64, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for i8

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<i8, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for i16

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<i16, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for i32

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<i32, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for i64

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<i64, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for i128

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<i128, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for isize

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<isize, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for u8

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<u8, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

#### fn from_byte_slice(vec: &[u8]) -> Option<Vec<u8>>

Source§

#### fn from_byte_vec(vec: Vec<u8>) -> Result<Vec<u8>, ParsingError>

Source§

### impl FromRedisValue for u16

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<u16, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for u32

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<u32, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for u64

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<u64, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for u128

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<u128, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for ()

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<(), ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<(), ParsingError>

Source§

### impl FromRedisValue for usize

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<usize, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for CString

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<CString, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<CString, ParsingError>

Source§

### impl FromRedisValue for String

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Self, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for BigInt

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<BigInt, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for BigUint

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<BigUint, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for Uuid

Available on crate feature `uuid` only.
Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Self, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for BigDecimal

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<BigDecimal, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for Bytes

Available on crate feature `bytes` only.
Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Self, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl FromRedisValue for Decimal

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Decimal, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<BTreeMap<K, V>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<BTreeMap<K, V>, ParsingError>

Source§

### impl<K, V> FromRedisValue for AHashMap<K, V>
where K: FromRedisValue + Eq + Hash, V: FromRedisValue,

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<AHashMap<K, V>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<AHashMap<K, V>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<HashMap<K, V, S>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<HashMap<K, V, S>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<HashMap<K, V, S>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<HashMap<K, V, S>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<BTreeSet<T>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<BTreeSet<T>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<AHashSet<T>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<AHashSet<T>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<HashSet<T, S>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<HashSet<T, S>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<HashSet<T, S>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<HashSet<T, S>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Option<T>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Option<T>, ParsingError>

Source§

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

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<(T,), ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<(T,), ParsingError>

Source§

#### fn from_redis_value_refs(items: &[Value]) -> Result<Vec<(T,)>, ParsingError>

Source§

#### fn from_each_redis_values(items: Vec<Value>) -> Vec<Result<(T,), ParsingError>>

Source§

#### fn from_redis_values(items: Vec<Value>) -> Result<Vec<(T,)>, ParsingError>

Source§

### impl<T: FromRedisValue> FromRedisValue for Box<[T]>

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Box<[T]>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Box<[T]>, ParsingError>

Source§

### impl<T: FromRedisValue> FromRedisValue for Box<T>

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Self, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl<T: FromRedisValue> FromRedisValue for Rc<T>

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Self, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

### impl<T: FromRedisValue> FromRedisValue for Arc<[T]>

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Arc<[T]>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Arc<[T]>, ParsingError>

Source§

### impl<T: FromRedisValue> FromRedisValue for Arc<T>

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Self, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(v: &Value) -> Result<Vec<T>, ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Vec<T>, ParsingError>

Source§

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

Source§

#### fn from_redis_value_ref(value: &Value) -> Result<[T; N], ParsingError>

Source§

#### fn from_redis_value(v: Value) -> Result<Self, ParsingError>

## Implementors§

Source§

### impl FromRedisValue for IntegerReplyOrNoOp

Source§

### impl FromRedisValue for Role

Source§

### impl FromRedisValue for Value

Source§

### impl FromRedisValue for ValueType

Source§

### impl FromRedisValue for StreamPendingReply

Available on crate feature `streams` only.
Source§

### impl FromRedisValue for XAckDelStatusCode

Available on crate feature `streams` only.
Source§

### impl FromRedisValue for XDelExStatusCode

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 StreamAutoClaimReply

Available on crate feature `streams` 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 FromRedisValue for ReplicaInfo

Source§

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

Available on crate feature `geospatial` only.
Source§

### impl<T: FromRedisValue> FromRedisValue for RedisResult<T>