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

Conversation

danni-m
Copy link
Contributor

@danni-m danni-m commented Aug 14, 2022

No description provided.

@danni-m
Copy link
Contributor Author

danni-m commented Aug 14, 2022

This would also help to fix #631

@djc
Copy link
Contributor

djc commented Aug 15, 2022

I'm fine with the Clone. I'm a little on the fence about exposing the implementation detail that we're using a HashMap here. What about instead implementing an iterator over (key, value) items?

(Clippy failures can be ignored, see #663.)

@danni-m
Copy link
Contributor Author

danni-m commented Sep 4, 2022

@djc first of all, it is possible, and I can do it to move with this PR (Should we implement a new Iterator or just expose a slice?).
My use case is more specific for orchestrating Redis instances where we need a lot more than get for Redis info. We preferred not to implement our own parser and use the one provided by the library, but at some point, we were limited by the API.
My reasoning for exposing Hashmap:

  1. Hashmap already provides a lot of useful APIs (like get, len and keys for example)
  2. We do use hashmap internally. There's not a lot of value (IMHO) in recreating the same APIs that hashmap already supports.

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think we should probably implement Deref<Target = &HashMap<String, Value>> instead of adding as_map(). That would also allow us to get rid of some of the simple proxy methods.

@danni-m
Copy link
Contributor Author

danni-m commented Sep 7, 2022

@djc removed as_map in favour of Deref

@djc
Copy link
Contributor

djc commented Sep 7, 2022

Thanks! @jaymell want to take a look?

@jaymell
Copy link
Contributor

jaymell commented Sep 8, 2022

Looks good!

@jaymell jaymell merged commit 0302280 into redis-rs:main Sep 8, 2022
nonirosenfeldredis pushed a commit to nonirosenfeldredis/redis-rs that referenced this pull request Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants