Enum aws_sdk_ec2::model::DomainType
source · #[non_exhaustive]
pub enum DomainType {
Standard,
Vpc,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against DomainType
, 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 domaintype = unimplemented!();
match domaintype {
DomainType::Standard => { /* ... */ },
DomainType::Vpc => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when domaintype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant DomainType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
DomainType::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 DomainType::NewFeature
is defined.
Specifically, when domaintype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on DomainType::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
Standard
Vpc
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl DomainType
impl DomainType
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
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
pub fn serialize_operation_crate_operation_allocate_address(
input: &crate::input::AllocateAddressInput,
) -> Result<aws_smithy_http::body::SdkBody, aws_smithy_http::operation::error::SerializationError> {
let mut out = String::new();
#[allow(unused_mut)]
let mut writer = aws_smithy_query::QueryWriter::new(&mut out, "AllocateAddress", "2016-11-15");
#[allow(unused_mut)]
let mut scope_49 = writer.prefix("Domain");
if let Some(var_50) = &input.domain {
scope_49.string(var_50.as_str());
}
#[allow(unused_mut)]
let mut scope_51 = writer.prefix("Address");
if let Some(var_52) = &input.address {
scope_51.string(var_52);
}
#[allow(unused_mut)]
let mut scope_53 = writer.prefix("PublicIpv4Pool");
if let Some(var_54) = &input.public_ipv4_pool {
scope_53.string(var_54);
}
#[allow(unused_mut)]
let mut scope_55 = writer.prefix("NetworkBorderGroup");
if let Some(var_56) = &input.network_border_group {
scope_55.string(var_56);
}
#[allow(unused_mut)]
let mut scope_57 = writer.prefix("CustomerOwnedIpv4Pool");
if let Some(var_58) = &input.customer_owned_ipv4_pool {
scope_57.string(var_58);
}
#[allow(unused_mut)]
let mut scope_59 = writer.prefix("DryRun");
if let Some(var_60) = &input.dry_run {
scope_59.boolean(*var_60);
}
#[allow(unused_mut)]
let mut scope_61 = writer.prefix("TagSpecification");
if let Some(var_62) = &input.tag_specifications {
let mut list_64 = scope_61.start_list(true, Some("item"));
for item_63 in var_62 {
#[allow(unused_mut)]
let mut entry_65 = list_64.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(entry_65, item_63)?;
}
list_64.finish();
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for DomainType
impl AsRef<str> for DomainType
source§impl Clone for DomainType
impl Clone for DomainType
source§fn clone(&self) -> DomainType
fn clone(&self) -> DomainType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DomainType
impl Debug for DomainType
source§impl From<&str> for DomainType
impl From<&str> for DomainType
source§impl FromStr for DomainType
impl FromStr for DomainType
source§impl Hash for DomainType
impl Hash for DomainType
source§impl Ord for DomainType
impl Ord for DomainType
source§fn cmp(&self, other: &DomainType) -> Ordering
fn cmp(&self, other: &DomainType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<DomainType> for DomainType
impl PartialEq<DomainType> for DomainType
source§fn eq(&self, other: &DomainType) -> bool
fn eq(&self, other: &DomainType) -> bool
source§impl PartialOrd<DomainType> for DomainType
impl PartialOrd<DomainType> for DomainType
source§fn partial_cmp(&self, other: &DomainType) -> Option<Ordering>
fn partial_cmp(&self, other: &DomainType) -> 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 DomainType
impl StructuralEq for DomainType
impl StructuralPartialEq for DomainType
Auto Trait Implementations§
impl RefUnwindSafe for DomainType
impl Send for DomainType
impl Sync for DomainType
impl Unpin for DomainType
impl UnwindSafe for DomainType
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.