Trait redis::FromRedisValue
source · pub trait FromRedisValue: Sized {
// Required method
fn from_redis_value(v: &Value) -> RedisResult<Self>;
// Provided methods
fn from_owned_redis_value(v: Value) -> RedisResult<Self> { ... }
fn from_redis_values(items: &[Value]) -> RedisResult<Vec<Self>> { ... }
fn from_owned_redis_values(items: Vec<Value>) -> RedisResult<Vec<Self>> { ... }
fn from_byte_vec(_vec: &[u8]) -> Option<Vec<Self>> { ... }
fn from_owned_byte_vec(_vec: Vec<u8>) -> RedisResult<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§
sourcefn from_redis_value(v: &Value) -> RedisResult<Self>
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§
sourcefn from_owned_redis_value(v: Value) -> RedisResult<Self>
fn from_owned_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.
sourcefn from_redis_values(items: &[Value]) -> RedisResult<Vec<Self>>
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.
sourcefn from_owned_redis_values(items: Vec<Value>) -> RedisResult<Vec<Self>>
fn from_owned_redis_values(items: Vec<Value>) -> RedisResult<Vec<Self>>
The same as from_redis_values
, but takes a Vec<Value>
instead
of a &[Value]
.
sourcefn from_byte_vec(_vec: &[u8]) -> Option<Vec<Self>>
fn from_byte_vec(_vec: &[u8]) -> Option<Vec<Self>>
Convert bytes to a single element vector.
sourcefn from_owned_byte_vec(_vec: Vec<u8>) -> RedisResult<Vec<Self>>
fn from_owned_byte_vec(_vec: Vec<u8>) -> RedisResult<Vec<Self>>
Convert bytes to a single element vector.
Object Safety§
Implementations on Foreign Types§
source§impl FromRedisValue for bool
impl FromRedisValue for bool
fn from_redis_value(v: &Value) -> RedisResult<bool>
source§impl FromRedisValue for f32
impl FromRedisValue for f32
fn from_redis_value(v: &Value) -> RedisResult<f32>
source§impl FromRedisValue for f64
impl FromRedisValue for f64
fn from_redis_value(v: &Value) -> RedisResult<f64>
source§impl FromRedisValue for i8
impl FromRedisValue for i8
fn from_redis_value(v: &Value) -> RedisResult<i8>
source§impl FromRedisValue for i16
impl FromRedisValue for i16
fn from_redis_value(v: &Value) -> RedisResult<i16>
source§impl FromRedisValue for i32
impl FromRedisValue for i32
fn from_redis_value(v: &Value) -> RedisResult<i32>
source§impl FromRedisValue for i64
impl FromRedisValue for i64
fn from_redis_value(v: &Value) -> RedisResult<i64>
source§impl FromRedisValue for i128
impl FromRedisValue for i128
fn from_redis_value(v: &Value) -> RedisResult<i128>
source§impl FromRedisValue for isize
impl FromRedisValue for isize
fn from_redis_value(v: &Value) -> RedisResult<isize>
source§impl FromRedisValue for u8
impl FromRedisValue for u8
fn from_redis_value(v: &Value) -> RedisResult<u8>
fn from_byte_vec(vec: &[u8]) -> Option<Vec<u8>>
fn from_owned_byte_vec(vec: Vec<u8>) -> RedisResult<Vec<u8>>
source§impl FromRedisValue for u16
impl FromRedisValue for u16
fn from_redis_value(v: &Value) -> RedisResult<u16>
source§impl FromRedisValue for u32
impl FromRedisValue for u32
fn from_redis_value(v: &Value) -> RedisResult<u32>
source§impl FromRedisValue for u64
impl FromRedisValue for u64
fn from_redis_value(v: &Value) -> RedisResult<u64>
source§impl FromRedisValue for u128
impl FromRedisValue for u128
fn from_redis_value(v: &Value) -> RedisResult<u128>
source§impl FromRedisValue for ()
impl FromRedisValue for ()
fn from_redis_value(_v: &Value) -> RedisResult<()>
source§impl FromRedisValue for usize
impl FromRedisValue for usize
fn from_redis_value(v: &Value) -> RedisResult<usize>
source§impl FromRedisValue for CString
impl FromRedisValue for CString
fn from_redis_value(v: &Value) -> RedisResult<CString>
fn from_owned_redis_value(v: Value) -> RedisResult<CString>
source§impl FromRedisValue for String
impl FromRedisValue for String
fn from_redis_value(v: &Value) -> RedisResult<String>
fn from_owned_redis_value(v: Value) -> RedisResult<String>
source§impl FromRedisValue for BigDecimal
impl FromRedisValue for BigDecimal
fn from_redis_value(v: &Value) -> RedisResult<BigDecimal>
source§impl FromRedisValue for Bytes
impl FromRedisValue for Bytes
fn from_redis_value(v: &Value) -> RedisResult<Self>
fn from_owned_redis_value(v: Value) -> RedisResult<Self>
source§impl FromRedisValue for BigInt
impl FromRedisValue for BigInt
fn from_redis_value(v: &Value) -> RedisResult<BigInt>
source§impl FromRedisValue for BigUint
impl FromRedisValue for BigUint
fn from_redis_value(v: &Value) -> RedisResult<BigUint>
source§impl FromRedisValue for Decimal
impl FromRedisValue for Decimal
fn from_redis_value(v: &Value) -> RedisResult<Decimal>
source§impl FromRedisValue for Uuid
impl FromRedisValue for Uuid
fn from_redis_value(v: &Value) -> RedisResult<Self>
source§impl<K, V: FromRedisValue> FromRedisValue for BTreeMap<K, V>
impl<K, V: FromRedisValue> FromRedisValue for BTreeMap<K, V>
fn from_redis_value(v: &Value) -> RedisResult<BTreeMap<K, V>>
fn from_owned_redis_value(v: Value) -> RedisResult<BTreeMap<K, V>>
source§impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue> FromRedisValue for AHashMap<K, V>
impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue> FromRedisValue for AHashMap<K, V>
fn from_redis_value(v: &Value) -> RedisResult<AHashMap<K, V>>
fn from_owned_redis_value(v: Value) -> RedisResult<AHashMap<K, V>>
source§impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue, S: BuildHasher + Default> FromRedisValue for HashMap<K, V, S>
impl<K: FromRedisValue + Eq + Hash, V: FromRedisValue, S: BuildHasher + Default> FromRedisValue for HashMap<K, V, S>
fn from_redis_value(v: &Value) -> RedisResult<HashMap<K, V, S>>
fn from_owned_redis_value(v: Value) -> RedisResult<HashMap<K, V, S>>
source§impl<T> FromRedisValue for BTreeSet<T>
impl<T> FromRedisValue for BTreeSet<T>
fn from_redis_value(v: &Value) -> RedisResult<BTreeSet<T>>
fn from_owned_redis_value(v: Value) -> RedisResult<BTreeSet<T>>
source§impl<T: FromRedisValue + Eq + Hash> FromRedisValue for AHashSet<T>
impl<T: FromRedisValue + Eq + Hash> FromRedisValue for AHashSet<T>
fn from_redis_value(v: &Value) -> RedisResult<AHashSet<T>>
fn from_owned_redis_value(v: Value) -> RedisResult<AHashSet<T>>
source§impl<T: FromRedisValue + Eq + Hash, S: BuildHasher + Default> FromRedisValue for HashSet<T, S>
impl<T: FromRedisValue + Eq + Hash, S: BuildHasher + Default> FromRedisValue for HashSet<T, S>
fn from_redis_value(v: &Value) -> RedisResult<HashSet<T, S>>
fn from_owned_redis_value(v: Value) -> RedisResult<HashSet<T, S>>
source§impl<T: FromRedisValue> FromRedisValue for Option<T>
impl<T: FromRedisValue> FromRedisValue for Option<T>
fn from_redis_value(v: &Value) -> RedisResult<Option<T>>
fn from_owned_redis_value(v: Value) -> RedisResult<Option<T>>
source§impl<T: FromRedisValue> FromRedisValue for Box<[T]>
impl<T: FromRedisValue> FromRedisValue for Box<[T]>
fn from_redis_value(v: &Value) -> RedisResult<Box<[T]>>
fn from_owned_redis_value(v: Value) -> RedisResult<Box<[T]>>
source§impl<T: FromRedisValue> FromRedisValue for Arc<[T]>
impl<T: FromRedisValue> FromRedisValue for Arc<[T]>
fn from_redis_value(v: &Value) -> RedisResult<Arc<[T]>>
fn from_owned_redis_value(v: Value) -> RedisResult<Arc<[T]>>
source§impl<T: FromRedisValue> FromRedisValue for Vec<T>
impl<T: FromRedisValue> FromRedisValue for Vec<T>
fn from_redis_value(v: &Value) -> RedisResult<Vec<T>>
fn from_owned_redis_value(v: Value) -> RedisResult<Vec<T>>
source§impl<T: FromRedisValue, const N: usize> FromRedisValue for [T; N]
impl<T: FromRedisValue, const N: usize> FromRedisValue for [T; N]
fn from_redis_value(value: &Value) -> RedisResult<[T; N]>
Implementors§
impl FromRedisValue for Value
impl FromRedisValue for StreamPendingReply
streams
only.impl FromRedisValue for AclInfo
acl
only.impl FromRedisValue for RadiusSearchResult
geospatial
only.impl FromRedisValue for StreamClaimReply
streams
only.impl FromRedisValue for StreamInfoConsumersReply
streams
only.impl FromRedisValue for StreamInfoGroupsReply
streams
only.impl FromRedisValue for StreamInfoStreamReply
streams
only.impl FromRedisValue for StreamPendingCountReply
streams
only.impl FromRedisValue for StreamRangeReply
streams
only.impl FromRedisValue for StreamReadReply
streams
only.impl FromRedisValue for InfoDict
impl<T: FromRedisValue> FromRedisValue for Coord<T>
geospatial
only.