Open cmbrandenburg opened 7 years ago
This pull request does not make the Environment
type generic with respect to read-only vs read-write access. I think doing so is a good idea because it would close the remaining loophole in the lmdb-rs type system that allows an application to call database-modifying methods on an environment opened as read-only, but it's unclear to me how the EnvBuilder::open
method should be adjusted to make this work. (EDIT: We would also need to make the DbHandle
type generic.)
Note that this pull request has nothing to do with issue #48. Whereas, this PR deals with read-only vs read-write access, that issue deals with unsafe lifetimes.
This commit unifies the
Transaction
andReadonlyTransaction
types into a singleTransaction
type that is generic with respect to whether the transaction is read-only or read-write. There are two new type definitions,ReadOnlyTransaction
andReadWriteTransaction
, which should provide some syntactic sugar for applications.Similarly, this commit changes the
Database
type to be generic with respect to read-only vs read-write access, as well as creating two new type definitions,ReadOnlyDatabase
andReadWriteDatabase
. Read-only databases only provide non-mutating methods. For example, it will be a compiler error for an application to call theput
method on aReadOnlyDatabase
.