Enum aws_sdk_amplifybackend::model::Service
source · #[non_exhaustive]
pub enum Service {
Cognito,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against Service
, 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 service = unimplemented!();
match service {
Service::Cognito => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when service
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant Service::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
Service::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 Service::NewFeature
is defined.
Specifically, when service
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on Service::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
Cognito
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl Service
impl Service
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
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
pub fn serialize_structure_crate_model_create_backend_auth_resource_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CreateBackendAuthResourceConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_70) = &input.auth_resources {
object.key("authResources").string(var_70.as_str());
}
if let Some(var_71) = &input.identity_pool_configs {
#[allow(unused_mut)]
let mut object_72 = object.key("identityPoolConfigs").start_object();
crate::json_ser::serialize_structure_crate_model_create_backend_auth_identity_pool_config(
&mut object_72,
var_71,
)?;
object_72.finish();
}
if let Some(var_73) = &input.service {
object.key("service").string(var_73.as_str());
}
if let Some(var_74) = &input.user_pool_configs {
#[allow(unused_mut)]
let mut object_75 = object.key("userPoolConfigs").start_object();
crate::json_ser::serialize_structure_crate_model_create_backend_auth_user_pool_config(
&mut object_75,
var_74,
)?;
object_75.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_create_backend_storage_resource_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CreateBackendStorageResourceConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_76) = &input.bucket_name {
object.key("bucketName").string(var_76.as_str());
}
if let Some(var_77) = &input.permissions {
#[allow(unused_mut)]
let mut object_78 = object.key("permissions").start_object();
crate::json_ser::serialize_structure_crate_model_backend_storage_permissions(
&mut object_78,
var_77,
)?;
object_78.finish();
}
if let Some(var_79) = &input.service_name {
object.key("serviceName").string(var_79.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_model_update_backend_auth_resource_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::UpdateBackendAuthResourceConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_80) = &input.auth_resources {
object.key("authResources").string(var_80.as_str());
}
if let Some(var_81) = &input.identity_pool_configs {
#[allow(unused_mut)]
let mut object_82 = object.key("identityPoolConfigs").start_object();
crate::json_ser::serialize_structure_crate_model_update_backend_auth_identity_pool_config(
&mut object_82,
var_81,
)?;
object_82.finish();
}
if let Some(var_83) = &input.service {
object.key("service").string(var_83.as_str());
}
if let Some(var_84) = &input.user_pool_configs {
#[allow(unused_mut)]
let mut object_85 = object.key("userPoolConfigs").start_object();
crate::json_ser::serialize_structure_crate_model_update_backend_auth_user_pool_config(
&mut object_85,
var_84,
)?;
object_85.finish();
}
Ok(())
}
Trait Implementations§
source§impl Ord for Service
impl Ord for Service
source§impl PartialOrd<Service> for Service
impl PartialOrd<Service> for Service
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 Service
impl StructuralEq for Service
impl StructuralPartialEq for Service
Auto Trait Implementations§
impl RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnwindSafe for Service
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.