Crates.io | megadex_derive |
lib.rs | megadex_derive |
version | 0.1.0 |
source | src |
created_at | 2019-01-17 01:37:48.588434 |
updated_at | 2019-01-17 01:37:48.588434 |
description | Syntactic sugar for managing collections of structs which have multiple indexed accessors. |
homepage | https://github.com/rrichardson/megadex |
repository | https://github.com/rrichardson/megadex |
max_upload_size | |
id | 109057 |
size | 13,786 |
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)
#[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)