Enum aws_sdk_lexmodelsv2::model::Effect
source · #[non_exhaustive]
pub enum Effect {
Allow,
Deny,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against Effect, 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 effect = unimplemented!();
match effect {
Effect::Allow => { /* ... */ },
Effect::Deny => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when effect represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant Effect::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
Effect::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 Effect::NewFeature is defined.
Specifically, when effect represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on Effect::NewFeature also yielding "NewFeature".
Explicitly matching on the Unknown variant should
be avoided for two reasons:
- The inner data
UnknownVariantValueis 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
Allow
Deny
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl Effect
impl Effect
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
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
pub fn serialize_structure_crate_input_create_resource_policy_statement_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateResourcePolicyStatementInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_74) = &input.action {
let mut array_75 = object.key("action").start_array();
for item_76 in var_74 {
{
array_75.value().string(item_76.as_str());
}
}
array_75.finish();
}
if let Some(var_77) = &input.condition {
#[allow(unused_mut)]
let mut object_78 = object.key("condition").start_object();
for (key_79, value_80) in var_77 {
{
#[allow(unused_mut)]
let mut object_81 = object_78.key(key_79.as_str()).start_object();
for (key_82, value_83) in value_80 {
{
object_81.key(key_82.as_str()).string(value_83.as_str());
}
}
object_81.finish();
}
}
object_78.finish();
}
if let Some(var_84) = &input.effect {
object.key("effect").string(var_84.as_str());
}
if let Some(var_85) = &input.principal {
let mut array_86 = object.key("principal").start_array();
for item_87 in var_85 {
{
#[allow(unused_mut)]
let mut object_88 = array_86.value().start_object();
crate::json_ser::serialize_structure_crate_model_principal(
&mut object_88,
item_87,
)?;
object_88.finish();
}
}
array_86.finish();
}
if let Some(var_89) = &input.statement_id {
object.key("statementId").string(var_89.as_str());
}
Ok(())
}Trait Implementations§
source§impl Ord for Effect
impl Ord for Effect
source§impl PartialOrd<Effect> for Effect
impl PartialOrd<Effect> for Effect
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 Effect
impl StructuralEq for Effect
impl StructuralPartialEq for Effect
Auto Trait Implementations§
impl RefUnwindSafe for Effect
impl Send for Effect
impl Sync for Effect
impl Unpin for Effect
impl UnwindSafe for Effect
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.