aws_sdk_dynamodbstreams/types/_attribute_value.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Represents the data for an attribute.</p>
4/// <p>Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.</p>
5/// <p>For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes">Data Types</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
6#[non_exhaustive]
7#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
8pub enum AttributeValue {
9 /// <p>An attribute of type Binary. For example:</p>
10 /// <p><code>"B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"</code></p>
11 B(::aws_smithy_types::Blob),
12 /// <p>An attribute of type Boolean. For example:</p>
13 /// <p><code>"BOOL": true</code></p>
14 Bool(bool),
15 /// <p>An attribute of type Binary Set. For example:</p>
16 /// <p><code>"BS": \["U3Vubnk=", "UmFpbnk=", "U25vd3k="\]</code></p>
17 Bs(::std::vec::Vec<::aws_smithy_types::Blob>),
18 /// <p>An attribute of type List. For example:</p>
19 /// <p><code>"L": \[ {"S": "Cookies"} , {"S": "Coffee"}, {"N": "3.14159"}\]</code></p>
20 L(::std::vec::Vec<crate::types::AttributeValue>),
21 /// <p>An attribute of type Map. For example:</p>
22 /// <p><code>"M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}</code></p>
23 M(::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>),
24 /// <p>An attribute of type Number. For example:</p>
25 /// <p><code>"N": "123.45"</code></p>
26 /// <p>Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.</p>
27 N(::std::string::String),
28 /// <p>An attribute of type Number Set. For example:</p>
29 /// <p><code>"NS": \["42.2", "-19", "7.5", "3.14"\]</code></p>
30 /// <p>Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.</p>
31 Ns(::std::vec::Vec<::std::string::String>),
32 /// <p>An attribute of type Null. For example:</p>
33 /// <p><code>"NULL": true</code></p>
34 Null(bool),
35 /// <p>An attribute of type String. For example:</p>
36 /// <p><code>"S": "Hello"</code></p>
37 S(::std::string::String),
38 /// <p>An attribute of type String Set. For example:</p>
39 /// <p><code>"SS": \["Giraffe", "Hippo" ,"Zebra"\]</code></p>
40 Ss(::std::vec::Vec<::std::string::String>),
41 /// The `Unknown` variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
42 /// An unknown enum variant
43 ///
44 /// _Note: If you encounter this error, consider upgrading your SDK to the latest version._
45 /// The `Unknown` variant represents cases where the server sent a value that wasn't recognized
46 /// by the client. This can happen when the server adds new functionality, but the client has not been updated.
47 /// To investigate this, consider turning on debug logging to print the raw HTTP response.
48 #[non_exhaustive]
49 Unknown,
50}
51impl AttributeValue {
52 /// Tries to convert the enum instance into [`B`](crate::types::AttributeValue::B), extracting the inner [`Blob`](::aws_smithy_types::Blob).
53 /// Returns `Err(&Self)` if it can't be converted.
54 pub fn as_b(&self) -> ::std::result::Result<&::aws_smithy_types::Blob, &Self> {
55 if let AttributeValue::B(val) = &self {
56 ::std::result::Result::Ok(val)
57 } else {
58 ::std::result::Result::Err(self)
59 }
60 }
61 /// Returns true if this is a [`B`](crate::types::AttributeValue::B).
62 pub fn is_b(&self) -> bool {
63 self.as_b().is_ok()
64 }
65 /// Tries to convert the enum instance into [`Bool`](crate::types::AttributeValue::Bool), extracting the inner [`bool`](bool).
66 /// Returns `Err(&Self)` if it can't be converted.
67 pub fn as_bool(&self) -> ::std::result::Result<&bool, &Self> {
68 if let AttributeValue::Bool(val) = &self {
69 ::std::result::Result::Ok(val)
70 } else {
71 ::std::result::Result::Err(self)
72 }
73 }
74 /// Returns true if this is a [`Bool`](crate::types::AttributeValue::Bool).
75 pub fn is_bool(&self) -> bool {
76 self.as_bool().is_ok()
77 }
78 /// Tries to convert the enum instance into [`Bs`](crate::types::AttributeValue::Bs), extracting the inner [`Vec`](::std::vec::Vec).
79 /// Returns `Err(&Self)` if it can't be converted.
80 pub fn as_bs(&self) -> ::std::result::Result<&::std::vec::Vec<::aws_smithy_types::Blob>, &Self> {
81 if let AttributeValue::Bs(val) = &self {
82 ::std::result::Result::Ok(val)
83 } else {
84 ::std::result::Result::Err(self)
85 }
86 }
87 /// Returns true if this is a [`Bs`](crate::types::AttributeValue::Bs).
88 pub fn is_bs(&self) -> bool {
89 self.as_bs().is_ok()
90 }
91 /// Tries to convert the enum instance into [`L`](crate::types::AttributeValue::L), extracting the inner [`Vec`](::std::vec::Vec).
92 /// Returns `Err(&Self)` if it can't be converted.
93 pub fn as_l(&self) -> ::std::result::Result<&::std::vec::Vec<crate::types::AttributeValue>, &Self> {
94 if let AttributeValue::L(val) = &self {
95 ::std::result::Result::Ok(val)
96 } else {
97 ::std::result::Result::Err(self)
98 }
99 }
100 /// Returns true if this is a [`L`](crate::types::AttributeValue::L).
101 pub fn is_l(&self) -> bool {
102 self.as_l().is_ok()
103 }
104 /// Tries to convert the enum instance into [`M`](crate::types::AttributeValue::M), extracting the inner [`HashMap`](::std::collections::HashMap).
105 /// Returns `Err(&Self)` if it can't be converted.
106 pub fn as_m(&self) -> ::std::result::Result<&::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>, &Self> {
107 if let AttributeValue::M(val) = &self {
108 ::std::result::Result::Ok(val)
109 } else {
110 ::std::result::Result::Err(self)
111 }
112 }
113 /// Returns true if this is a [`M`](crate::types::AttributeValue::M).
114 pub fn is_m(&self) -> bool {
115 self.as_m().is_ok()
116 }
117 /// Tries to convert the enum instance into [`N`](crate::types::AttributeValue::N), extracting the inner [`String`](::std::string::String).
118 /// Returns `Err(&Self)` if it can't be converted.
119 pub fn as_n(&self) -> ::std::result::Result<&::std::string::String, &Self> {
120 if let AttributeValue::N(val) = &self {
121 ::std::result::Result::Ok(val)
122 } else {
123 ::std::result::Result::Err(self)
124 }
125 }
126 /// Returns true if this is a [`N`](crate::types::AttributeValue::N).
127 pub fn is_n(&self) -> bool {
128 self.as_n().is_ok()
129 }
130 /// Tries to convert the enum instance into [`Ns`](crate::types::AttributeValue::Ns), extracting the inner [`Vec`](::std::vec::Vec).
131 /// Returns `Err(&Self)` if it can't be converted.
132 pub fn as_ns(&self) -> ::std::result::Result<&::std::vec::Vec<::std::string::String>, &Self> {
133 if let AttributeValue::Ns(val) = &self {
134 ::std::result::Result::Ok(val)
135 } else {
136 ::std::result::Result::Err(self)
137 }
138 }
139 /// Returns true if this is a [`Ns`](crate::types::AttributeValue::Ns).
140 pub fn is_ns(&self) -> bool {
141 self.as_ns().is_ok()
142 }
143 /// Tries to convert the enum instance into [`Null`](crate::types::AttributeValue::Null), extracting the inner [`bool`](bool).
144 /// Returns `Err(&Self)` if it can't be converted.
145 pub fn as_null(&self) -> ::std::result::Result<&bool, &Self> {
146 if let AttributeValue::Null(val) = &self {
147 ::std::result::Result::Ok(val)
148 } else {
149 ::std::result::Result::Err(self)
150 }
151 }
152 /// Returns true if this is a [`Null`](crate::types::AttributeValue::Null).
153 pub fn is_null(&self) -> bool {
154 self.as_null().is_ok()
155 }
156 /// Tries to convert the enum instance into [`S`](crate::types::AttributeValue::S), extracting the inner [`String`](::std::string::String).
157 /// Returns `Err(&Self)` if it can't be converted.
158 pub fn as_s(&self) -> ::std::result::Result<&::std::string::String, &Self> {
159 if let AttributeValue::S(val) = &self {
160 ::std::result::Result::Ok(val)
161 } else {
162 ::std::result::Result::Err(self)
163 }
164 }
165 /// Returns true if this is a [`S`](crate::types::AttributeValue::S).
166 pub fn is_s(&self) -> bool {
167 self.as_s().is_ok()
168 }
169 /// Tries to convert the enum instance into [`Ss`](crate::types::AttributeValue::Ss), extracting the inner [`Vec`](::std::vec::Vec).
170 /// Returns `Err(&Self)` if it can't be converted.
171 pub fn as_ss(&self) -> ::std::result::Result<&::std::vec::Vec<::std::string::String>, &Self> {
172 if let AttributeValue::Ss(val) = &self {
173 ::std::result::Result::Ok(val)
174 } else {
175 ::std::result::Result::Err(self)
176 }
177 }
178 /// Returns true if this is a [`Ss`](crate::types::AttributeValue::Ss).
179 pub fn is_ss(&self) -> bool {
180 self.as_ss().is_ok()
181 }
182 /// Returns true if the enum instance is the `Unknown` variant.
183 pub fn is_unknown(&self) -> bool {
184 matches!(self, Self::Unknown)
185 }
186}