#[non_exhaustive]
pub enum ComparisonOperator {
Show 14 variants
BeginsWith,
Between,
Contains,
Eq,
Ge,
Gt,
In,
Le,
Lt,
Ne,
NotContains,
NotNull,
Null,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ComparisonOperator
, it is important to ensure
your code is forward-compatible. That is, if a match arm handles a case for a
feature that is supported by the service but has not been represented as an enum
variant in a current version of SDK, your code should continue to work when you
upgrade SDK to a future version in which the enum does include a variant for that
feature.
Here is an example of how you can make a match expression forward-compatible:
# let comparisonoperator = unimplemented!();
match comparisonoperator {
ComparisonOperator::BeginsWith => { /* ... */ },
ComparisonOperator::Between => { /* ... */ },
ComparisonOperator::Contains => { /* ... */ },
ComparisonOperator::Eq => { /* ... */ },
ComparisonOperator::Ge => { /* ... */ },
ComparisonOperator::Gt => { /* ... */ },
ComparisonOperator::In => { /* ... */ },
ComparisonOperator::Le => { /* ... */ },
ComparisonOperator::Lt => { /* ... */ },
ComparisonOperator::Ne => { /* ... */ },
ComparisonOperator::NotContains => { /* ... */ },
ComparisonOperator::NotNull => { /* ... */ },
ComparisonOperator::Null => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when comparisonoperator
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ComparisonOperator::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ComparisonOperator::Unknown(UnknownVariantValue("NewFeature".to_owned()))
and calling as_str
on it yields "NewFeature"
.
This match expression is forward-compatible when executed with a newer
version of SDK where the variant ComparisonOperator::NewFeature
is defined.
Specifically, when comparisonoperator
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ComparisonOperator::NewFeature
also yielding "NewFeature"
.
Explicitly matching on the Unknown
variant should
be avoided for two reasons:
- The inner data
UnknownVariantValue
is opaque, and no further information can be extracted. - It might inadvertently shadow other intended match arms.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BeginsWith
Between
Contains
Eq
Ge
Gt
In
Le
Lt
Ne
NotContains
NotNull
Null
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ComparisonOperator
impl ComparisonOperator
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the &str
value of the enum member.
Examples found in repository?
More examples
2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347
pub fn serialize_structure_crate_model_expected_attribute_value(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::ExpectedAttributeValue,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_479) = &input.value {
#[allow(unused_mut)]
let mut object_480 = object.key("Value").start_object();
crate::json_ser::serialize_union_crate_model_attribute_value(&mut object_480, var_479)?;
object_480.finish();
}
if let Some(var_481) = &input.exists {
object.key("Exists").boolean(*var_481);
}
if let Some(var_482) = &input.comparison_operator {
object.key("ComparisonOperator").string(var_482.as_str());
}
if let Some(var_483) = &input.attribute_value_list {
let mut array_484 = object.key("AttributeValueList").start_array();
for item_485 in var_483 {
{
#[allow(unused_mut)]
let mut object_486 = array_484.value().start_object();
crate::json_ser::serialize_union_crate_model_attribute_value(
&mut object_486,
item_485,
)?;
object_486.finish();
}
}
array_484.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_parameterized_statement(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::ParameterizedStatement,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_487) = &input.statement {
object.key("Statement").string(var_487.as_str());
}
if let Some(var_488) = &input.parameters {
let mut array_489 = object.key("Parameters").start_array();
for item_490 in var_488 {
{
#[allow(unused_mut)]
let mut object_491 = array_489.value().start_object();
crate::json_ser::serialize_union_crate_model_attribute_value(
&mut object_491,
item_490,
)?;
object_491.finish();
}
}
array_489.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_s3_bucket_source(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::S3BucketSource,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_492) = &input.s3_bucket_owner {
object.key("S3BucketOwner").string(var_492.as_str());
}
if let Some(var_493) = &input.s3_bucket {
object.key("S3Bucket").string(var_493.as_str());
}
if let Some(var_494) = &input.s3_key_prefix {
object.key("S3KeyPrefix").string(var_494.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_model_input_format_options(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::InputFormatOptions,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_495) = &input.csv {
#[allow(unused_mut)]
let mut object_496 = object.key("Csv").start_object();
crate::json_ser::serialize_structure_crate_model_csv_options(&mut object_496, var_495)?;
object_496.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_table_creation_parameters(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::TableCreationParameters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_497) = &input.table_name {
object.key("TableName").string(var_497.as_str());
}
if let Some(var_498) = &input.attribute_definitions {
let mut array_499 = object.key("AttributeDefinitions").start_array();
for item_500 in var_498 {
{
#[allow(unused_mut)]
let mut object_501 = array_499.value().start_object();
crate::json_ser::serialize_structure_crate_model_attribute_definition(
&mut object_501,
item_500,
)?;
object_501.finish();
}
}
array_499.finish();
}
if let Some(var_502) = &input.key_schema {
let mut array_503 = object.key("KeySchema").start_array();
for item_504 in var_502 {
{
#[allow(unused_mut)]
let mut object_505 = array_503.value().start_object();
crate::json_ser::serialize_structure_crate_model_key_schema_element(
&mut object_505,
item_504,
)?;
object_505.finish();
}
}
array_503.finish();
}
if let Some(var_506) = &input.billing_mode {
object.key("BillingMode").string(var_506.as_str());
}
if let Some(var_507) = &input.provisioned_throughput {
#[allow(unused_mut)]
let mut object_508 = object.key("ProvisionedThroughput").start_object();
crate::json_ser::serialize_structure_crate_model_provisioned_throughput(
&mut object_508,
var_507,
)?;
object_508.finish();
}
if let Some(var_509) = &input.sse_specification {
#[allow(unused_mut)]
let mut object_510 = object.key("SSESpecification").start_object();
crate::json_ser::serialize_structure_crate_model_sse_specification(
&mut object_510,
var_509,
)?;
object_510.finish();
}
if let Some(var_511) = &input.global_secondary_indexes {
let mut array_512 = object.key("GlobalSecondaryIndexes").start_array();
for item_513 in var_511 {
{
#[allow(unused_mut)]
let mut object_514 = array_512.value().start_object();
crate::json_ser::serialize_structure_crate_model_global_secondary_index(
&mut object_514,
item_513,
)?;
object_514.finish();
}
}
array_512.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_condition(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::Condition,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_515) = &input.attribute_value_list {
let mut array_516 = object.key("AttributeValueList").start_array();
for item_517 in var_515 {
{
#[allow(unused_mut)]
let mut object_518 = array_516.value().start_object();
crate::json_ser::serialize_union_crate_model_attribute_value(
&mut object_518,
item_517,
)?;
object_518.finish();
}
}
array_516.finish();
}
if let Some(var_519) = &input.comparison_operator {
object.key("ComparisonOperator").string(var_519.as_str());
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for ComparisonOperator
impl AsRef<str> for ComparisonOperator
source§impl Clone for ComparisonOperator
impl Clone for ComparisonOperator
source§fn clone(&self) -> ComparisonOperator
fn clone(&self) -> ComparisonOperator
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ComparisonOperator
impl Debug for ComparisonOperator
source§impl From<&str> for ComparisonOperator
impl From<&str> for ComparisonOperator
source§impl FromStr for ComparisonOperator
impl FromStr for ComparisonOperator
source§impl Hash for ComparisonOperator
impl Hash for ComparisonOperator
source§impl Ord for ComparisonOperator
impl Ord for ComparisonOperator
source§fn cmp(&self, other: &ComparisonOperator) -> Ordering
fn cmp(&self, other: &ComparisonOperator) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ComparisonOperator> for ComparisonOperator
impl PartialEq<ComparisonOperator> for ComparisonOperator
source§fn eq(&self, other: &ComparisonOperator) -> bool
fn eq(&self, other: &ComparisonOperator) -> bool
source§impl PartialOrd<ComparisonOperator> for ComparisonOperator
impl PartialOrd<ComparisonOperator> for ComparisonOperator
source§fn partial_cmp(&self, other: &ComparisonOperator) -> Option<Ordering>
fn partial_cmp(&self, other: &ComparisonOperator) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for ComparisonOperator
impl StructuralEq for ComparisonOperator
impl StructuralPartialEq for ComparisonOperator
Auto Trait Implementations§
impl RefUnwindSafe for ComparisonOperator
impl Send for ComparisonOperator
impl Sync for ComparisonOperator
impl Unpin for ComparisonOperator
impl UnwindSafe for ComparisonOperator
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.