#lmdb #db #macro #accessor #rkv

macro megadex_derive

Syntactic sugar for managing collections of structs which have multiple indexed accessors

1 unstable release

0.1.0 Jan 17, 2019

#27 in #accessor

MIT license

11KB
162 lines

Megadex Derive

Build Status Build status

A procedural macro which provides a Derive trait called Megadex

This provides the use of two field-level attributes: #[id] and #[indexed]

You use id to indicate which field in your struct contains the primary key.

You use indexed to indicate any fields by which you want to retrieve this (and other) struct(s)

Usage:


#[derive(Megadex)]
struct Foo {
  #[id]
  my_id: String,
  weeee: String,
  #[indexed]
  bar: String,

  #[indexed]
  baz: String,
}

// This would add these methods to your struct: 

fn save(&self)

fn insert(id, other)

fn erase(&self)

fn del(id, other) 

fn get(id, other)

fn find_by_bar(key: &String)

fn id_by_bar(key: &String)

fn find_by_baz(key: &String)

fn id_by_bar(key: &String)

Dependencies

~2MB
~48K SLoC