#[non_exhaustive]
pub enum AdTriggersElement {
Break,
DistributorAdvertisement,
DistributorOverlayPlacementOpportunity,
DistributorPlacementOpportunity,
ProviderAdvertisement,
ProviderOverlayPlacementOpportunity,
ProviderPlacementOpportunity,
SpliceInsert,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against AdTriggersElement
, 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 adtriggerselement = unimplemented!();
match adtriggerselement {
AdTriggersElement::Break => { /* ... */ },
AdTriggersElement::DistributorAdvertisement => { /* ... */ },
AdTriggersElement::DistributorOverlayPlacementOpportunity => { /* ... */ },
AdTriggersElement::DistributorPlacementOpportunity => { /* ... */ },
AdTriggersElement::ProviderAdvertisement => { /* ... */ },
AdTriggersElement::ProviderOverlayPlacementOpportunity => { /* ... */ },
AdTriggersElement::ProviderPlacementOpportunity => { /* ... */ },
AdTriggersElement::SpliceInsert => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when adtriggerselement
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant AdTriggersElement::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
AdTriggersElement::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 AdTriggersElement::NewFeature
is defined.
Specifically, when adtriggerselement
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on AdTriggersElement::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
Break
DistributorAdvertisement
DistributorOverlayPlacementOpportunity
DistributorPlacementOpportunity
ProviderAdvertisement
ProviderOverlayPlacementOpportunity
ProviderPlacementOpportunity
SpliceInsert
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl AdTriggersElement
impl AdTriggersElement
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 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
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(())
}
pub fn serialize_structure_crate_model_hls_package(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::HlsPackage,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_92) = &input.ad_markers {
object.key("adMarkers").string(var_92.as_str());
}
if let Some(var_93) = &input.ad_triggers {
let mut array_94 = object.key("adTriggers").start_array();
for item_95 in var_93 {
{
array_94.value().string(item_95.as_str());
}
}
array_94.finish();
}
if let Some(var_96) = &input.ads_on_delivery_restrictions {
object
.key("adsOnDeliveryRestrictions")
.string(var_96.as_str());
}
if let Some(var_97) = &input.encryption {
#[allow(unused_mut)]
let mut object_98 = object.key("encryption").start_object();
crate::json_ser::serialize_structure_crate_model_hls_encryption(&mut object_98, var_97)?;
object_98.finish();
}
if input.include_dvb_subtitles {
object
.key("includeDvbSubtitles")
.boolean(input.include_dvb_subtitles);
}
if input.include_iframe_only_stream {
object
.key("includeIframeOnlyStream")
.boolean(input.include_iframe_only_stream);
}
if let Some(var_99) = &input.playlist_type {
object.key("playlistType").string(var_99.as_str());
}
if input.playlist_window_seconds != 0 {
object.key("playlistWindowSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.playlist_window_seconds).into()),
);
}
if input.program_date_time_interval_seconds != 0 {
object.key("programDateTimeIntervalSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.program_date_time_interval_seconds).into()),
);
}
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_100) = &input.stream_selection {
#[allow(unused_mut)]
let mut object_101 = object.key("streamSelection").start_object();
crate::json_ser::serialize_structure_crate_model_stream_selection(
&mut object_101,
var_100,
)?;
object_101.finish();
}
if input.use_audio_rendition_group {
object
.key("useAudioRenditionGroup")
.boolean(input.use_audio_rendition_group);
}
Ok(())
}
pub fn serialize_structure_crate_model_mss_package(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::MssPackage,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_102) = &input.encryption {
#[allow(unused_mut)]
let mut object_103 = object.key("encryption").start_object();
crate::json_ser::serialize_structure_crate_model_mss_encryption(&mut object_103, var_102)?;
object_103.finish();
}
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.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_104) = &input.stream_selection {
#[allow(unused_mut)]
let mut object_105 = object.key("streamSelection").start_object();
crate::json_ser::serialize_structure_crate_model_stream_selection(
&mut object_105,
var_104,
)?;
object_105.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_cmaf_encryption(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CmafEncryption,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_106) = &input.constant_initialization_vector {
object
.key("constantInitializationVector")
.string(var_106.as_str());
}
if let Some(var_107) = &input.encryption_method {
object.key("encryptionMethod").string(var_107.as_str());
}
if input.key_rotation_interval_seconds != 0 {
object.key("keyRotationIntervalSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.key_rotation_interval_seconds).into()),
);
}
if let Some(var_108) = &input.speke_key_provider {
#[allow(unused_mut)]
let mut object_109 = object.key("spekeKeyProvider").start_object();
crate::json_ser::serialize_structure_crate_model_speke_key_provider(
&mut object_109,
var_108,
)?;
object_109.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_hls_manifest_create_or_update_parameters(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::HlsManifestCreateOrUpdateParameters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_110) = &input.ad_markers {
object.key("adMarkers").string(var_110.as_str());
}
if let Some(var_111) = &input.ad_triggers {
let mut array_112 = object.key("adTriggers").start_array();
for item_113 in var_111 {
{
array_112.value().string(item_113.as_str());
}
}
array_112.finish();
}
if let Some(var_114) = &input.ads_on_delivery_restrictions {
object
.key("adsOnDeliveryRestrictions")
.string(var_114.as_str());
}
if let Some(var_115) = &input.id {
object.key("id").string(var_115.as_str());
}
if input.include_iframe_only_stream {
object
.key("includeIframeOnlyStream")
.boolean(input.include_iframe_only_stream);
}
if let Some(var_116) = &input.manifest_name {
object.key("manifestName").string(var_116.as_str());
}
if let Some(var_117) = &input.playlist_type {
object.key("playlistType").string(var_117.as_str());
}
if input.playlist_window_seconds != 0 {
object.key("playlistWindowSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.playlist_window_seconds).into()),
);
}
if input.program_date_time_interval_seconds != 0 {
object.key("programDateTimeIntervalSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((input.program_date_time_interval_seconds).into()),
);
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for AdTriggersElement
impl AsRef<str> for AdTriggersElement
source§impl Clone for AdTriggersElement
impl Clone for AdTriggersElement
source§fn clone(&self) -> AdTriggersElement
fn clone(&self) -> AdTriggersElement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AdTriggersElement
impl Debug for AdTriggersElement
source§impl From<&str> for AdTriggersElement
impl From<&str> for AdTriggersElement
source§impl FromStr for AdTriggersElement
impl FromStr for AdTriggersElement
source§impl Hash for AdTriggersElement
impl Hash for AdTriggersElement
source§impl Ord for AdTriggersElement
impl Ord for AdTriggersElement
source§fn cmp(&self, other: &AdTriggersElement) -> Ordering
fn cmp(&self, other: &AdTriggersElement) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<AdTriggersElement> for AdTriggersElement
impl PartialEq<AdTriggersElement> for AdTriggersElement
source§fn eq(&self, other: &AdTriggersElement) -> bool
fn eq(&self, other: &AdTriggersElement) -> bool
source§impl PartialOrd<AdTriggersElement> for AdTriggersElement
impl PartialOrd<AdTriggersElement> for AdTriggersElement
source§fn partial_cmp(&self, other: &AdTriggersElement) -> Option<Ordering>
fn partial_cmp(&self, other: &AdTriggersElement) -> 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 AdTriggersElement
impl StructuralEq for AdTriggersElement
impl StructuralPartialEq for AdTriggersElement
Auto Trait Implementations§
impl RefUnwindSafe for AdTriggersElement
impl Send for AdTriggersElement
impl Sync for AdTriggersElement
impl Unpin for AdTriggersElement
impl UnwindSafe for AdTriggersElement
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.