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

Read-only and read-write Database and Transaction #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Read-only and read-write Database and Transaction #49

wants to merge 1 commit into from

Conversation

cmbrandenburg
Copy link
Contributor

This commit unifies the Transaction and ReadonlyTransaction types
into a single Transaction type that is generic with respect to whether
the transaction is read-only or read-write. There are two new type
definitions, ReadOnlyTransaction and ReadWriteTransaction, 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 and ReadWriteDatabase. Read-only
databases only provide non-mutating methods. For example, it will be a
compiler error for an application to call the put method on a
ReadOnlyDatabase.

This commit unifies the `Transaction` and `ReadonlyTransaction` types
into a single `Transaction` type that is generic with respect to whether
the transaction is read-only or read-write. There are two new type
definitions, `ReadOnlyTransaction` and `ReadWriteTransaction`, 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` and `ReadWriteDatabase`. Read-only
databases only provide non-mutating methods. For example, it will be a
compiler error for an application to call the `put` method on a
`ReadOnlyDatabase`.
@cmbrandenburg
Copy link
Contributor Author

cmbrandenburg commented Jun 17, 2017

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.

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.

1 participant