-
Notifications
You must be signed in to change notification settings - Fork 52
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
Unify *Reader
and *Writer
#95
Comments
This seems reasonable to me, and it's consistent with the design foreshadowed by the unimplemented
Note the refactoring in #62, based on discussion in #46, where we chose |
I have two concerns with the Writer being the primary collection of functionality:
With reader/writer : (note the names are not terribly important) impl Writer {
fn get_first(MultiStore, Key) -> Value;
fn get_multi(MultiStore, Key) -> Iter<Value>;
fn get_bytes(Store, Key) -> Value;
fn get_int(IntStore, Key) -> Int;
fn put*
.... Notice the overlap of get_bytes, get_first.. there would likely be similar for delete, insert and maybe put. If we divided the functionality among the stores.. it would be impl MultiStore {
fn get(Reader, Key) -> Iter<Value>;
fn get_first(Reader, Key) -> Value;
fn put(Writer, Key, Value) -> Value;
}
impl Store {
fn get(Reader, Key) -> Value;
fn put(Writer, Key, Value) -> Value;
} This seems like a much more sane delineation of signatures.. also.. in this model, there is nothing stopping you from doing : If we want to simplify the interface further.. we can make |
also, with regards to #46, it seems that the sticking point was with the fact that stores needed to be |
I created #97 to better illustrate the two proposed sets of APIs. |
The interface was changed in 0.8 (in #101) to require a mutable reference for a Line 63 in 9ff784c
Could you elaborate why? Since |
I am not sure if there is a good reason why I did that. We should discuss this in a new ticket, though, since I was about to close this since it's no longer relevant. |
Presently there are 2 transaction types (plus the proposed Multi*) for both Read and Write transactions.
There doesn't have to be, though. In fact, it's causing problems when I want to execute a transaction over different types of
Store
sI see two options:
The easiest option is pull the functions from
Integer*
andMulti*
into Reader and Writer, and suffixing them with_int
and_multi
. They will take IntStore and MultiStore as parameters respectively.The harder, but perhaps cleaner option is a significant chunk of refactoring:
Move the accessor functions into the
*Store
structs themselves. Make the the functions accept either a Reader or a Writer. This way we'll have more ergonomic and intuitive methods like:For maximum modularity.. I would make a new trait:
ReadTransaction
which can be implemented by both Reader and Writer.. since you can fetch values in Write transactions as well.The text was updated successfully, but these errors were encountered: