[][src]Crate dynomite_derive

Provides procedural macros for deriving dynomite types for your structs and enum types


This example is not tested
use dynomite::{Item, FromAttributes, Attributes};
use dynomite::dynamodb::AttributeValue;

// derive Item
#[derive(Item, PartialEq, Debug, Clone)]
struct Person {
  #[dynomite(partition_key)] id: String

  let person = Person { id: "123".into() };
  // convert person to string keys and attribute values
  let attributes: Attributes = person.clone().into();
  // convert attributes into person type
  assert_eq!(person, Person::from_attrs(attributes).unwrap());

  // dynamodb types require only primary key attributes and may contain
  // other fields. when looking up items only those key attributes are required
  // dynomite derives a new {Name}Key struct for your which contains
  // only those and also implements Item
  let key = PersonKey { id: "123".into() };
  let key_attributes: Attributes = key.clone().into();
  // convert attributes into person type
  assert_eq!(key, PersonKey::from_attrs(key_attributes).unwrap());

Derive Macros


Derives dynomite::Attribute for enum types


similar in spirit to #[derive(Item)] except these are exempt from declaring partition and sort keys


Derives dynomite::Item type for struts with named fields