-
Notifications
You must be signed in to change notification settings - Fork 60
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
Change the lifetimes of the Iter
types
#111
Comments
Hey @Diggsey, As I told you, I am not sure it is possible to implement this API, at least in this exact way. The problem with it is that it asks for a mutable reference of the database when the cursor itself contains an immutable reference of it already. What do you think ? Were you thinking about another API ? |
I read through the LMDB docs, and their model seems to look like this:
This layout will avoid the need for all dynamic checks except when you first open a transaction, whilst also allowing the various Rust types to be thin wrappers around the underlying LMDB handles. |
A great idea from @Diggsey to fix #108, an issue where we were allowing the user to keep reference from inside the database while modifying it at the same time.
It could be a great solution to indeed have differences between the immutable iterators i.e.
RoIter
,RoPrefixIter
, and the mutable ones i.e.RwIter
,RwPrefixIter
. Where the only differences would be with the lifetimes of the key and values returned, the read-only version would simply return entries with a lifetime of the initial transaction, while the read-write one would return entries with a lifetime that comes from the database itself and takes a new parameter a mutable reference of the database, this way we make sure that we can't keep values while also modifying the database.I am not sure it will work as the initial
Database::iter_mut
method asks for a&Database
and theRwIter::put_current
can only be used with the&mut Database
parameter, I am not sure that Rust will accept that. Will try when I got time.The text was updated successfully, but these errors were encountered: