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

Add blanket implementation(s) #34

Open
iqualfragile opened this issue May 12, 2016 · 2 comments
Open

Add blanket implementation(s) #34

iqualfragile opened this issue May 12, 2016 · 2 comments

Comments

@iqualfragile
Copy link

It would be nice to be able to insert and retrieve values more easily, therefore i propose to include a (extremly trivial) blanket implementation for ToMdbValue and/or FromMdbValue for everything that implements the serde Serialize and/or Deserialize trait using for examble bincode for serialisation.

@xitep
Copy link
Collaborator

xitep commented Jun 26, 2016

Hm, I'm not really convinced it is worth the 3rd party dependencies. However, I could imagine this to be an optional feature.

  1. How would lmdb-rs deal with the fact that serialization/deserialization can fail for some reason? Even today the FromMdbValue implementation for String (uses .unwrap()) and &str (might produce an invalid utf8 string) is problematic.
  2. How difficult is to read such encoded data from other programming languages?

@iqualfragile
Copy link
Author

the reason im asking you to implement this over just doing it myself is because i literally can not do that. Rust disallows me to, because both Traits are from foreign crates.
Yes, as an optional, compile-time-enabled feature would be the right way to go, especially as currently both serde and rustc-serialize exist and support for both might be positive.

  1. I would just panic. Im not quite sure how serialization could fail besides going out of memory, which is a crash in things like arrays, too. Deserialization could in fact fail, but you do not expect your database to contain corrupted data, thats just not something you are gona code for. External input, ok, but the database that you just wrote to now containing broken data, no.
  2. That depends on which serialization is used. Maybe allowing two options there would be a good idea. Bincode for a space-efficient encoding, and json/some kind of slightly binarized json for interoperability. I do believe that the main use case for a local memory mapped key-value database is in fact using it with the same software.

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

No branches or pull requests

2 participants