@@ -76,25 +76,25 @@ See below for more information on schema design for Cryptonamo tables.
76
76
77
77
#### Annotating a Cryptanomo Type
78
78
79
- To use Cryptonamo, you must first annotate a struct with the ` Cryptonamo ` derive macro .
79
+ To use Cryptonamo, you must first annotate a struct with the the derive macros for the Cryptonamo traits you wish to implement .
80
80
81
81
``` rust
82
- use cryptonamo :: Cryptonamo ;
82
+ use cryptonamo :: { Encryptable , Decryptable , Searchable } ;
83
83
84
- #[derive(Cryptonamo )]
85
- #[cryptonamo(partition_key = " email" )]
84
+ #[derive(Debug , Encryptable , Decryptable , Searchable )]
86
85
struct User {
87
86
name : String ,
87
+
88
+ #[partition_key]
88
89
email : String ,
89
90
}
90
91
```
91
92
92
- The ` Cryptonamo ` derive macro will generate implementations of the following traits:
93
+ This example implements the traits:
93
94
94
- * ` Cryptonamo ` - a top-level trait that sets up the table name and partition key
95
- * ` DecryptedRecord ` - a trait that allows you to decrypt a record from DynamoDB
96
- * ` EncryptedRecord ` - a trait that allows you to encrypt a record for storage in DynamoDB
97
- * ` SearchableRecord ` - a trait that allows you to search for records in DynamoDB
95
+ * ` Decryptable ` - a trait that allows you to decrypt the record from DynamoDB
96
+ * ` Encryptable ` - a trait that allows you to encrypt the record for storage in DynamoDB
97
+ * ` Searchable ` - a trait that allows you to search for records in DynamoDB
98
98
99
99
The above example is the minimum required to use Cryptonamo however you can expand capabilities via several macros.
100
100
@@ -107,8 +107,8 @@ To store a field as a plaintext, use the `plaintext` attribute:
107
107
use cryptonamo :: Cryptonamo ;
108
108
109
109
#[derive(Cryptonamo )]
110
- #[cryptonamo(partition_key = " email" )]
111
110
struct User {
111
+ #[partition_key]
112
112
email : String ,
113
113
name : String ,
114
114
@@ -133,8 +133,8 @@ If you don't want a field stored in the the database at all, you can annotate th
133
133
use cryptonamo :: Cryptonamo ;
134
134
135
135
#[derive(Cryptonamo )]
136
- #[cryptonamo(partition_key = " email" )]
137
136
struct User {
137
+ #[partition_key]
138
138
email : String ,
139
139
name : String ,
140
140
@@ -174,9 +174,9 @@ To index a field, use the `query` attribute:
174
174
use cryptonamo :: Cryptonamo ;
175
175
176
176
#[derive(Cryptonamo )]
177
- #[cryptonamo(partition_key = " email" )]
178
177
struct User {
179
178
#[cryptonamo(query = " exact" )]
179
+ #[partition_key]
180
180
email : String ,
181
181
182
182
#[cryptonamo(query = " prefix" )]
@@ -191,9 +191,9 @@ All indexes with the same compound name are combined into a single index.
191
191
use cryptonamo :: Cryptonamo ;
192
192
193
193
#[derive(Cryptonamo )]
194
- #[cryptonamo(partition_key = " email" )]
195
194
struct User {
196
195
#[cryptonamo(query = " exact" , compound = " email#name" )]
196
+ #[partition_key]
197
197
email : String ,
198
198
199
199
#[cryptonamo(query = " prefix" , compound = " email#name" )]
@@ -292,9 +292,9 @@ For example, you might want to store related records to `User` such as `License`
292
292
use cryptonamo :: Cryptonamo ;
293
293
294
294
#[derive(Cryptonamo )]
295
- #[cryptonamo(partition_key = " user_email" )]
296
295
struct License {
297
296
#[cryptonamo(query = " exact" )]
297
+ #[partition_key]
298
298
user_email : String ,
299
299
300
300
#[cryptonamo(plaintext)]
@@ -312,9 +312,9 @@ For example, you might want to query users by name using a prefix (say for using
312
312
313
313
``` rust
314
314
#[derive(Cryptonamo )]
315
- #[cryptonamo(partition_key = " email" )]
316
315
pub struct UserView {
317
316
#[cryptonamo(skip)]
317
+ #[partition_key]
318
318
email : String ,
319
319
320
320
#[cryptonamo(query = " prefix" )]
0 commit comments