Add DB generic type instead of dyn Trait to allow use the DB outside of the trie #206
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.
Hello,
This crate is awesome and provides a lot of flexibility and cool features. Thanks for this very nice work.
When we used it, we had a problem with the way you hold the DB. In the
TrieDBMut
for example, you hold a mutable reference over the database that prevents us to have another reference in our code to do custom things such as modifying the DB content (in our case we save all changes that you make in the DB to allow user to rollback or rollforward his trie).We can have a reference (mutable or not) to our DB using your method
db()
ordb_mut()
but it only give us the reference over something that implementsHashDB
that allows us to use only the methods defined inHashDB
trait and not our custom ones.This PR propose to fix this problem by replacing the
dyn HashDB
by providing a concrete generic type that needs to implementHashDB
trait. This allow us to changedb()
anddb_mut()
to return our concrete type and be able to have fully access to the methods we created.I would love to have your feedback on this. If it's something you already encoured and you have other solutions, I will be very happy to heard them.
Thanks again for your work