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

Added ToMdbValue implementations #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

valarauca
Copy link

Changes

Added 2 new implementations of ToMdbValue for str and [u8] (the non-sized versions without pointers).

Goals

Makes it easier to implement traits like

pub trait GenericLMDBCursor<ActualDBData> {
   type Key: ActualDBData::Key+?Sized;
   type Value: ActualDBData::Value;
   // methods..
}
pub trait ActualDBData {
  type Key: ToMdbValue+?Sized;
  type Value: Message+MessageStatic; //protobuffers
  fn get_db_handle<'a>() -> &'a Database;
}
pub struct DocDB;
impl ActualDBData {
  type Key = str;
  type Value = DocProto;
  fn get_db_handle<'a>() -> &'a Database {
        get_cached_doc_handle()
   }
}

Effectively then I just have one fat trait that does all db stuff on abstract data. And a handful of ZeroSizedTypes which tell me what data I'm using.

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