Skip to content

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