Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add derive Clone and as_map method to InfoDict #661

Merged
merged 1 commit into from Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion redis/src/types.rs
Expand Up @@ -12,6 +12,7 @@ use std::string::FromUtf8Error;
pub(crate) use ahash::{AHashMap as HashMap, AHashSet as HashSet};
#[cfg(not(feature = "ahash"))]
pub(crate) use std::collections::{HashMap, HashSet};
use std::ops::Deref;

macro_rules! invalid_type_error {
($v:expr, $det:expr) => {{
Expand Down Expand Up @@ -548,7 +549,7 @@ pub type RedisResult<T> = Result<T, RedisError>;
pub type RedisFuture<'a, T> = futures_util::future::BoxFuture<'a, RedisResult<T>>;

/// An info dictionary type.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct InfoDict {
map: HashMap<String, Value>,
}
Expand Down Expand Up @@ -618,6 +619,14 @@ impl InfoDict {
}
}

impl Deref for InfoDict {
type Target = HashMap<String, Value>;

fn deref(&self) -> &Self::Target {
&self.map
}
}

/// Abstraction trait for redis command abstractions.
pub trait RedisWrite {
/// Accepts a serialized redis command.
Expand Down