-
Notifications
You must be signed in to change notification settings - Fork 246
Expose keys & erase_all fns on EspKeyValueStorage #641
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
Open
JacksonUtsch
wants to merge
3
commits into
esp-rs:master
Choose a base branch
from
JacksonUtsch:nvs-kvs-keys-erase
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+10
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
data_typeparameter of this new method does not make sense forEspKeyValueStorage. Also,EspNvsKeysshould be wrapped, as its next_key method returns a name + type, but we only care about the name.Finally, the
EspKeyValueStoragetype exists to be consumed primarily through theRawStoragetrait, so I wonder what's the point of having public methods on the ESP-IDF trait impl, and not on the trait itself?I mean, if you don't care about being platform-agnostic, or you do it your own way without the embedded-svc storage traits, why using EspKeyValueStorage in the first place? Isn't it better to use the wrapped EspNvs type directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right in that the
data_typedoes not make sense also the changed return type, can just useNoneinside the function and remove the parameter. See if my wrapping looks correct.I'm not sure the ergonomics of how
RawStorageis used. I am just usingEspKeyValueStoragedirectly as I need the ability for arbitrary data.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is EspNvs not fulfilling your arbitrary data requirement?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean
get_blobandset_blobspecifically? It was failing some reason and I saw the newer API ofEspKeyValueStorageKeysand tried it without issues. Why would we haveEspKeyValueStorageKeysthen?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - I mean
get_blobandset_blob. TheEspKeyValueStoragething IS implemented in terms of these two calls (mostly) after all and the only reason why it exists is so that we implement theRawStoragetrait. But then what exactly do you mean by mentioningEspKeyValueStorageKeysin this same context is beyond me. get/set_blob is for reading/writing values. The Keys thing is an iterator over the keys/values which are currently saved. So these two things serve two completely different purposes and why you are conflating those is beyond me.Also, creating new - potentially questionable APIs - because the existing ones "was failing some reason" is not a good argument for those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, I mean
EspKeyValueStoragenotEspKeyValueStorageKeys.EspKeyValueStorageis an existing API it would just be exposing the functionalities it did not seem to have which its underlying type has.I mean why is
EspKeyValueStoragea public API if it does not have basic functionalities supported?I don't know the usefulness of the
RawStoragetrait but the example code shows usingEspKeyValueStoragedirectly.You can question the APIs as that is a point of a PR, like those changes I made.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is wrong/out of date and needs to be fixed.
Again:
EspKeyValueStorage's purpose in life is to implement theRawStoragetrait. Does it implement it successfully? Yes. As to why is it public, well, how would you construct it otherwise? You might ask why it has other public methods then and that's valid kinda, but not like a super-strong argument. Then if you say its API's are not good enough you are basically sayingRawStorageAPIs are not good enough. Which is valid but then we have to actually extend theRawStorageAPI as well. Basically this and the second paragraph in there in particular all-over again.I mean, I don't know how to say it more clearly: if you don't care about
RawStorage, just use the damnEspNvsdirectly! :DIt has a richer API, its methods are transactional (unlike
EspKeyValueStorage), EspKeyValueStorage is anyway implemented on top of it so not sure why we are turning in circles here still?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay if it is not advisable to use
EspKeyValueStoragethen I will have to tryEspNvsagain with the blob functions and figure out where the issue is happening. FYI I am using JSONThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Json serde via get/set_blob should work just fine.