#[non_exhaustive]
pub enum PeriodTriggersElement {
Ads,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against PeriodTriggersElement
, 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 periodtriggerselement = unimplemented!();
match periodtriggerselement {
PeriodTriggersElement::Ads => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when periodtriggerselement
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant PeriodTriggersElement::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
PeriodTriggersElement::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 PeriodTriggersElement::NewFeature
is defined.
Specifically, when periodtriggerselement
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on PeriodTriggersElement::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
Ads
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl PeriodTriggersElement
impl PeriodTriggersElement
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
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
pub fn serialize_structure_crate_model_dash_package(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::DashPackage,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_76) = &input.ad_triggers {
let mut array_77 = object.key("adTriggers").start_array();
for item_78 in var_76 {
{
array_77.value().string(item_78.as_str());
}
}
array_77.finish();
}
if let Some(var_79) = &input.ads_on_delivery_restrictions {
object
.key("adsOnDeliveryRestrictions")
.string(var_79.as_str());
}
if let Some(var_80) = &input.encryption {
#[allow(unused_mut)]
let mut object_81 = object.key("encryption").start_object();
crate::json_ser::serialize_structure_crate_model_dash_encryption(&mut object_81, var_80)?;
object_81.finish();
}
if input.include_iframe_only_stream {
object
.key("includeIframeOnlyStream")
.boolean(input.include_iframe_only_stream);
}
if let Some(var_82) = &input.manifest_layout {
object.key("manifestLayout").string(var_82.as_str());
}
if input.manifest_window_seconds != 0 {
object.key("manifestWindowSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.manifest_window_seconds).into()),
);
}
if input.min_buffer_time_seconds != 0 {
object.key("minBufferTimeSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.min_buffer_time_seconds).into()),
);
}
if input.min_update_period_seconds != 0 {
object.key("minUpdatePeriodSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.min_update_period_seconds).into()),
);
}
if let Some(var_83) = &input.period_triggers {
let mut array_84 = object.key("periodTriggers").start_array();
for item_85 in var_83 {
{
array_84.value().string(item_85.as_str());
}
}
array_84.finish();
}
if let Some(var_86) = &input.profile {
object.key("profile").string(var_86.as_str());
}
if input.segment_duration_seconds != 0 {
object.key("segmentDurationSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.segment_duration_seconds).into()),
);
}
if let Some(var_87) = &input.segment_template_format {
object.key("segmentTemplateFormat").string(var_87.as_str());
}
if let Some(var_88) = &input.stream_selection {
#[allow(unused_mut)]
let mut object_89 = object.key("streamSelection").start_object();
crate::json_ser::serialize_structure_crate_model_stream_selection(&mut object_89, var_88)?;
object_89.finish();
}
if input.suggested_presentation_delay_seconds != 0 {
object.key("suggestedPresentationDelaySeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.suggested_presentation_delay_seconds).into()),
);
}
if let Some(var_90) = &input.utc_timing {
object.key("utcTiming").string(var_90.as_str());
}
if let Some(var_91) = &input.utc_timing_uri {
object.key("utcTimingUri").string(var_91.as_str());
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for PeriodTriggersElement
impl AsRef<str> for PeriodTriggersElement
source§impl Clone for PeriodTriggersElement
impl Clone for PeriodTriggersElement
source§fn clone(&self) -> PeriodTriggersElement
fn clone(&self) -> PeriodTriggersElement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PeriodTriggersElement
impl Debug for PeriodTriggersElement
source§impl From<&str> for PeriodTriggersElement
impl From<&str> for PeriodTriggersElement
source§impl FromStr for PeriodTriggersElement
impl FromStr for PeriodTriggersElement
source§impl Hash for PeriodTriggersElement
impl Hash for PeriodTriggersElement
source§impl Ord for PeriodTriggersElement
impl Ord for PeriodTriggersElement
source§fn cmp(&self, other: &PeriodTriggersElement) -> Ordering
fn cmp(&self, other: &PeriodTriggersElement) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<PeriodTriggersElement> for PeriodTriggersElement
impl PartialEq<PeriodTriggersElement> for PeriodTriggersElement
source§fn eq(&self, other: &PeriodTriggersElement) -> bool
fn eq(&self, other: &PeriodTriggersElement) -> bool
source§impl PartialOrd<PeriodTriggersElement> for PeriodTriggersElement
impl PartialOrd<PeriodTriggersElement> for PeriodTriggersElement
source§fn partial_cmp(&self, other: &PeriodTriggersElement) -> Option<Ordering>
fn partial_cmp(&self, other: &PeriodTriggersElement) -> 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 PeriodTriggersElement
impl StructuralEq for PeriodTriggersElement
impl StructuralPartialEq for PeriodTriggersElement
Auto Trait Implementations§
impl RefUnwindSafe for PeriodTriggersElement
impl Send for PeriodTriggersElement
impl Sync for PeriodTriggersElement
impl Unpin for PeriodTriggersElement
impl UnwindSafe for PeriodTriggersElement
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.