#[non_exhaustive]
pub enum LoaContentType {
Pdf,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against LoaContentType, 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 loacontenttype = unimplemented!();
match loacontenttype {
LoaContentType::Pdf => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when loacontenttype represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant LoaContentType::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
LoaContentType::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 LoaContentType::NewFeature is defined.
Specifically, when loacontenttype represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on LoaContentType::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
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl LoaContentType
impl LoaContentType
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
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
pub fn serialize_structure_crate_input_describe_connection_loa_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeConnectionLoaInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_127) = &input.connection_id {
object.key("connectionId").string(var_127.as_str());
}
if let Some(var_128) = &input.provider_name {
object.key("providerName").string(var_128.as_str());
}
if let Some(var_129) = &input.loa_content_type {
object.key("loaContentType").string(var_129.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_connections_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeConnectionsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_130) = &input.connection_id {
object.key("connectionId").string(var_130.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_connections_on_interconnect_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeConnectionsOnInterconnectInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_131) = &input.interconnect_id {
object.key("interconnectId").string(var_131.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_direct_connect_gateway_association_proposals_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeDirectConnectGatewayAssociationProposalsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_132) = &input.direct_connect_gateway_id {
object
.key("directConnectGatewayId")
.string(var_132.as_str());
}
if let Some(var_133) = &input.proposal_id {
object.key("proposalId").string(var_133.as_str());
}
if let Some(var_134) = &input.associated_gateway_id {
object.key("associatedGatewayId").string(var_134.as_str());
}
if let Some(var_135) = &input.max_results {
object.key("maxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_135).into()),
);
}
if let Some(var_136) = &input.next_token {
object.key("nextToken").string(var_136.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_direct_connect_gateway_associations_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeDirectConnectGatewayAssociationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_137) = &input.association_id {
object.key("associationId").string(var_137.as_str());
}
if let Some(var_138) = &input.associated_gateway_id {
object.key("associatedGatewayId").string(var_138.as_str());
}
if let Some(var_139) = &input.direct_connect_gateway_id {
object
.key("directConnectGatewayId")
.string(var_139.as_str());
}
if let Some(var_140) = &input.max_results {
object.key("maxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_140).into()),
);
}
if let Some(var_141) = &input.next_token {
object.key("nextToken").string(var_141.as_str());
}
if let Some(var_142) = &input.virtual_gateway_id {
object.key("virtualGatewayId").string(var_142.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_direct_connect_gateway_attachments_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeDirectConnectGatewayAttachmentsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_143) = &input.direct_connect_gateway_id {
object
.key("directConnectGatewayId")
.string(var_143.as_str());
}
if let Some(var_144) = &input.virtual_interface_id {
object.key("virtualInterfaceId").string(var_144.as_str());
}
if let Some(var_145) = &input.max_results {
object.key("maxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_145).into()),
);
}
if let Some(var_146) = &input.next_token {
object.key("nextToken").string(var_146.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_direct_connect_gateways_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeDirectConnectGatewaysInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_147) = &input.direct_connect_gateway_id {
object
.key("directConnectGatewayId")
.string(var_147.as_str());
}
if let Some(var_148) = &input.max_results {
object.key("maxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_148).into()),
);
}
if let Some(var_149) = &input.next_token {
object.key("nextToken").string(var_149.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_hosted_connections_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeHostedConnectionsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_150) = &input.connection_id {
object.key("connectionId").string(var_150.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_interconnect_loa_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeInterconnectLoaInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_151) = &input.interconnect_id {
object.key("interconnectId").string(var_151.as_str());
}
if let Some(var_152) = &input.provider_name {
object.key("providerName").string(var_152.as_str());
}
if let Some(var_153) = &input.loa_content_type {
object.key("loaContentType").string(var_153.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_interconnects_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeInterconnectsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_154) = &input.interconnect_id {
object.key("interconnectId").string(var_154.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_lags_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeLagsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_155) = &input.lag_id {
object.key("lagId").string(var_155.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_describe_loa_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DescribeLoaInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_156) = &input.connection_id {
object.key("connectionId").string(var_156.as_str());
}
if let Some(var_157) = &input.provider_name {
object.key("providerName").string(var_157.as_str());
}
if let Some(var_158) = &input.loa_content_type {
object.key("loaContentType").string(var_158.as_str());
}
Ok(())
}Trait Implementations§
source§impl AsRef<str> for LoaContentType
impl AsRef<str> for LoaContentType
source§impl Clone for LoaContentType
impl Clone for LoaContentType
source§fn clone(&self) -> LoaContentType
fn clone(&self) -> LoaContentType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for LoaContentType
impl Debug for LoaContentType
source§impl From<&str> for LoaContentType
impl From<&str> for LoaContentType
source§impl FromStr for LoaContentType
impl FromStr for LoaContentType
source§impl Hash for LoaContentType
impl Hash for LoaContentType
source§impl Ord for LoaContentType
impl Ord for LoaContentType
source§fn cmp(&self, other: &LoaContentType) -> Ordering
fn cmp(&self, other: &LoaContentType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<LoaContentType> for LoaContentType
impl PartialEq<LoaContentType> for LoaContentType
source§fn eq(&self, other: &LoaContentType) -> bool
fn eq(&self, other: &LoaContentType) -> bool
source§impl PartialOrd<LoaContentType> for LoaContentType
impl PartialOrd<LoaContentType> for LoaContentType
source§fn partial_cmp(&self, other: &LoaContentType) -> Option<Ordering>
fn partial_cmp(&self, other: &LoaContentType) -> 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 LoaContentType
impl StructuralEq for LoaContentType
impl StructuralPartialEq for LoaContentType
Auto Trait Implementations§
impl RefUnwindSafe for LoaContentType
impl Send for LoaContentType
impl Sync for LoaContentType
impl Unpin for LoaContentType
impl UnwindSafe for LoaContentType
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.