Enum aws_sdk_lambda::model::PackageType
source · #[non_exhaustive]
pub enum PackageType {
Image,
Zip,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against PackageType
, 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 packagetype = unimplemented!();
match packagetype {
PackageType::Image => { /* ... */ },
PackageType::Zip => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when packagetype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant PackageType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
PackageType::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 PackageType::NewFeature
is defined.
Specifically, when packagetype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on PackageType::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
Image
Zip
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl PackageType
impl PackageType
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
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 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
pub fn serialize_structure_crate_input_create_function_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateFunctionInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_59) = &input.architectures {
let mut array_60 = object.key("Architectures").start_array();
for item_61 in var_59 {
{
array_60.value().string(item_61.as_str());
}
}
array_60.finish();
}
if let Some(var_62) = &input.code {
#[allow(unused_mut)]
let mut object_63 = object.key("Code").start_object();
crate::json_ser::serialize_structure_crate_model_function_code(&mut object_63, var_62)?;
object_63.finish();
}
if let Some(var_64) = &input.code_signing_config_arn {
object.key("CodeSigningConfigArn").string(var_64.as_str());
}
if let Some(var_65) = &input.dead_letter_config {
#[allow(unused_mut)]
let mut object_66 = object.key("DeadLetterConfig").start_object();
crate::json_ser::serialize_structure_crate_model_dead_letter_config(
&mut object_66,
var_65,
)?;
object_66.finish();
}
if let Some(var_67) = &input.description {
object.key("Description").string(var_67.as_str());
}
if let Some(var_68) = &input.environment {
#[allow(unused_mut)]
let mut object_69 = object.key("Environment").start_object();
crate::json_ser::serialize_structure_crate_model_environment(&mut object_69, var_68)?;
object_69.finish();
}
if let Some(var_70) = &input.ephemeral_storage {
#[allow(unused_mut)]
let mut object_71 = object.key("EphemeralStorage").start_object();
crate::json_ser::serialize_structure_crate_model_ephemeral_storage(&mut object_71, var_70)?;
object_71.finish();
}
if let Some(var_72) = &input.file_system_configs {
let mut array_73 = object.key("FileSystemConfigs").start_array();
for item_74 in var_72 {
{
#[allow(unused_mut)]
let mut object_75 = array_73.value().start_object();
crate::json_ser::serialize_structure_crate_model_file_system_config(
&mut object_75,
item_74,
)?;
object_75.finish();
}
}
array_73.finish();
}
if let Some(var_76) = &input.function_name {
object.key("FunctionName").string(var_76.as_str());
}
if let Some(var_77) = &input.handler {
object.key("Handler").string(var_77.as_str());
}
if let Some(var_78) = &input.image_config {
#[allow(unused_mut)]
let mut object_79 = object.key("ImageConfig").start_object();
crate::json_ser::serialize_structure_crate_model_image_config(&mut object_79, var_78)?;
object_79.finish();
}
if let Some(var_80) = &input.kms_key_arn {
object.key("KMSKeyArn").string(var_80.as_str());
}
if let Some(var_81) = &input.layers {
let mut array_82 = object.key("Layers").start_array();
for item_83 in var_81 {
{
array_82.value().string(item_83.as_str());
}
}
array_82.finish();
}
if let Some(var_84) = &input.memory_size {
object.key("MemorySize").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_84).into()),
);
}
if let Some(var_85) = &input.package_type {
object.key("PackageType").string(var_85.as_str());
}
if input.publish {
object.key("Publish").boolean(input.publish);
}
if let Some(var_86) = &input.role {
object.key("Role").string(var_86.as_str());
}
if let Some(var_87) = &input.runtime {
object.key("Runtime").string(var_87.as_str());
}
if let Some(var_88) = &input.tags {
#[allow(unused_mut)]
let mut object_89 = object.key("Tags").start_object();
for (key_90, value_91) in var_88 {
{
object_89.key(key_90.as_str()).string(value_91.as_str());
}
}
object_89.finish();
}
if let Some(var_92) = &input.timeout {
object.key("Timeout").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_92).into()),
);
}
if let Some(var_93) = &input.tracing_config {
#[allow(unused_mut)]
let mut object_94 = object.key("TracingConfig").start_object();
crate::json_ser::serialize_structure_crate_model_tracing_config(&mut object_94, var_93)?;
object_94.finish();
}
if let Some(var_95) = &input.vpc_config {
#[allow(unused_mut)]
let mut object_96 = object.key("VpcConfig").start_object();
crate::json_ser::serialize_structure_crate_model_vpc_config(&mut object_96, var_95)?;
object_96.finish();
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for PackageType
impl AsRef<str> for PackageType
source§impl Clone for PackageType
impl Clone for PackageType
source§fn clone(&self) -> PackageType
fn clone(&self) -> PackageType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PackageType
impl Debug for PackageType
source§impl From<&str> for PackageType
impl From<&str> for PackageType
source§impl FromStr for PackageType
impl FromStr for PackageType
source§impl Hash for PackageType
impl Hash for PackageType
source§impl Ord for PackageType
impl Ord for PackageType
source§fn cmp(&self, other: &PackageType) -> Ordering
fn cmp(&self, other: &PackageType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<PackageType> for PackageType
impl PartialEq<PackageType> for PackageType
source§fn eq(&self, other: &PackageType) -> bool
fn eq(&self, other: &PackageType) -> bool
source§impl PartialOrd<PackageType> for PackageType
impl PartialOrd<PackageType> for PackageType
source§fn partial_cmp(&self, other: &PackageType) -> Option<Ordering>
fn partial_cmp(&self, other: &PackageType) -> 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 PackageType
impl StructuralEq for PackageType
impl StructuralPartialEq for PackageType
Auto Trait Implementations§
impl RefUnwindSafe for PackageType
impl Send for PackageType
impl Sync for PackageType
impl Unpin for PackageType
impl UnwindSafe for PackageType
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.