rustack_dynamodb_model/
operations.rs1use std::fmt;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum DynamoDBOperation {
8 CreateTable,
11 DeleteTable,
13 UpdateTable,
15 DescribeTable,
17 ListTables,
19
20 PutItem,
23 GetItem,
25 UpdateItem,
27 DeleteItem,
29
30 Query,
33 Scan,
35
36 BatchGetItem,
39 BatchWriteItem,
41
42 TagResource,
45 UntagResource,
47 ListTagsOfResource,
49
50 DescribeTimeToLive,
53 UpdateTimeToLive,
55
56 TransactGetItems,
59 TransactWriteItems,
61
62 DescribeLimits,
65 DescribeEndpoints,
67}
68
69impl DynamoDBOperation {
70 #[must_use]
72 pub fn as_str(&self) -> &'static str {
73 match self {
74 Self::CreateTable => "CreateTable",
75 Self::DeleteTable => "DeleteTable",
76 Self::UpdateTable => "UpdateTable",
77 Self::DescribeTable => "DescribeTable",
78 Self::ListTables => "ListTables",
79 Self::PutItem => "PutItem",
80 Self::GetItem => "GetItem",
81 Self::UpdateItem => "UpdateItem",
82 Self::DeleteItem => "DeleteItem",
83 Self::Query => "Query",
84 Self::Scan => "Scan",
85 Self::BatchGetItem => "BatchGetItem",
86 Self::BatchWriteItem => "BatchWriteItem",
87 Self::TagResource => "TagResource",
88 Self::UntagResource => "UntagResource",
89 Self::ListTagsOfResource => "ListTagsOfResource",
90 Self::DescribeTimeToLive => "DescribeTimeToLive",
91 Self::UpdateTimeToLive => "UpdateTimeToLive",
92 Self::TransactGetItems => "TransactGetItems",
93 Self::TransactWriteItems => "TransactWriteItems",
94 Self::DescribeLimits => "DescribeLimits",
95 Self::DescribeEndpoints => "DescribeEndpoints",
96 }
97 }
98
99 #[must_use]
101 pub fn from_name(name: &str) -> Option<Self> {
102 match name {
103 "CreateTable" => Some(Self::CreateTable),
104 "DeleteTable" => Some(Self::DeleteTable),
105 "UpdateTable" => Some(Self::UpdateTable),
106 "DescribeTable" => Some(Self::DescribeTable),
107 "ListTables" => Some(Self::ListTables),
108 "PutItem" => Some(Self::PutItem),
109 "GetItem" => Some(Self::GetItem),
110 "UpdateItem" => Some(Self::UpdateItem),
111 "DeleteItem" => Some(Self::DeleteItem),
112 "Query" => Some(Self::Query),
113 "Scan" => Some(Self::Scan),
114 "BatchGetItem" => Some(Self::BatchGetItem),
115 "BatchWriteItem" => Some(Self::BatchWriteItem),
116 "TagResource" => Some(Self::TagResource),
117 "UntagResource" => Some(Self::UntagResource),
118 "ListTagsOfResource" => Some(Self::ListTagsOfResource),
119 "DescribeTimeToLive" => Some(Self::DescribeTimeToLive),
120 "UpdateTimeToLive" => Some(Self::UpdateTimeToLive),
121 "TransactGetItems" => Some(Self::TransactGetItems),
122 "TransactWriteItems" => Some(Self::TransactWriteItems),
123 "DescribeLimits" => Some(Self::DescribeLimits),
124 "DescribeEndpoints" => Some(Self::DescribeEndpoints),
125 _ => None,
126 }
127 }
128}
129
130impl fmt::Display for DynamoDBOperation {
131 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
132 f.write_str(self.as_str())
133 }
134}