Struct redis_module::key::HMGetResult [−][src]
Opaque type used to hold multi-get results. Use the provided methods to convert the results into the desired type of Rust collection.
Trait Implementations
impl<'a, A, B> IntoIterator for HMGetResult<'a, A, B> where
A: Into<Vec<u8>> + Clone,
RedisString: Into<B>,
[src]
A: Into<Vec<u8>> + Clone,
RedisString: Into<B>,
type Item = (A, B)
The type of the elements being iterated over.
type IntoIter = HMGetIter<'a, A, B>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Provides an iterator over the multi-get results in the form of (field-name, field-value)
pairs. The type of field-name elements is the same as that passed to the original multi-
get call, while the field-value elements may be of any type for which a RedisString Into
conversion is implemented.
Examples
Get a HashMap
from the results:
use std::collections::HashMap; use redis_module::RedisError; let keyname = "config"; let fields = &["username", "password", "email"]; let hm = ctx .open_key(keyname) .hash_get_multi(fields)? .ok_or(RedisError::Str("ERR key not found"))?; let response: HashMap<&str, String> = hm.into_iter().collect();
Get a Vec
of only the field values from the results:
use redis_module::RedisError; let hm = ctx .open_key(keyname) .hash_get_multi(fields)? .ok_or(RedisError::Str("ERR key not found"))?; let response: Vec<String> = hm.into_iter().map(|(_, v)| v).collect();
Auto Trait Implementations
impl<'a, A, B> RefUnwindSafe for HMGetResult<'a, A, B> where
A: RefUnwindSafe,
B: RefUnwindSafe,
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<'a, A, B> !Send for HMGetResult<'a, A, B>
impl<'a, A, B> !Sync for HMGetResult<'a, A, B>
impl<'a, A, B> Unpin for HMGetResult<'a, A, B> where
B: Unpin,
B: Unpin,
impl<'a, A, B> UnwindSafe for HMGetResult<'a, A, B> where
A: RefUnwindSafe,
B: UnwindSafe,
A: RefUnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,