Open ramosbugs opened 3 years ago
Would you please rebase this on top of current master
to address CI issues unrelated to this PR (which have since been fixed)?
@ramosbugs I've added your PR in this fork: https://github.com/rust-serverless/dynomite/commit/bad13f5822461987ca18fdc7120945947947e578
If you have any additional ideas/issues/PR - please send them in the fork above since this repo is not actively maintained by the original author.
What did you implement:
The
Item
trait currently includes akey()
method that returns a map from attribute name to attribute value for either the partition key only or both the partition and sort keys. In the latter case, it's not possible to distinguish between the partition and sort key attributes without separate knowledge about which key is which.This PR adds
partition_key()
andsort_key()
methods to theItem
trait, which allow each key to be accessed separately. This makes it easier to write middleware and other generic code that works on multiple item types. Both methods are automatically implemented by thederive
proc macro.How did you verify your change:
Added some test cases, plus tested the code manually from my (separate) downstream crate.
What (if anything) would need to be called out in the CHANGELOG for the next release:
Since this PR adds new methods to the
Item
trait without providing a default implementation, it constitutes a breaking change for users that manually implement this trait rather than using thederive
proc macro.