megadex_derive 0.1.0

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

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)