Enum aws_sdk_schemas::model::Type
source · #[non_exhaustive]
pub enum Type {
JsonSchemaDraft4,
OpenApi3,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against Type
, 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 type = unimplemented!();
match type {
Type::JsonSchemaDraft4 => { /* ... */ },
Type::OpenApi3 => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when type
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant Type::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
Type::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 Type::NewFeature
is defined.
Specifically, when type
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on Type::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
JsonSchemaDraft4
OpenApi3
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl Type
impl Type
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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
pub fn serialize_structure_crate_input_create_schema_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateSchemaInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_12) = &input.content {
object.key("Content").string(var_12.as_str());
}
if let Some(var_13) = &input.description {
object.key("Description").string(var_13.as_str());
}
if let Some(var_14) = &input.tags {
#[allow(unused_mut)]
let mut object_15 = object.key("tags").start_object();
for (key_16, value_17) in var_14 {
{
object_15.key(key_16.as_str()).string(value_17.as_str());
}
}
object_15.finish();
}
if let Some(var_18) = &input.r#type {
object.key("Type").string(var_18.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_get_discovered_schema_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::GetDiscoveredSchemaInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_19) = &input.events {
let mut array_20 = object.key("Events").start_array();
for item_21 in var_19 {
{
array_20.value().string(item_21.as_str());
}
}
array_20.finish();
}
if let Some(var_22) = &input.r#type {
object.key("Type").string(var_22.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_put_resource_policy_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::PutResourcePolicyInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_23) = &input.policy {
object.key("Policy").string(var_23.as_str());
}
if let Some(var_24) = &input.revision_id {
object.key("RevisionId").string(var_24.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_tag_resource_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::TagResourceInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_25) = &input.tags {
#[allow(unused_mut)]
let mut object_26 = object.key("tags").start_object();
for (key_27, value_28) in var_25 {
{
object_26.key(key_27.as_str()).string(value_28.as_str());
}
}
object_26.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_update_discoverer_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::UpdateDiscovererInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if input.cross_account {
object.key("CrossAccount").boolean(input.cross_account);
}
if let Some(var_29) = &input.description {
object.key("Description").string(var_29.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_update_registry_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::UpdateRegistryInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_30) = &input.description {
object.key("Description").string(var_30.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_update_schema_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::UpdateSchemaInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_31) = &input.client_token_id {
object.key("ClientTokenId").string(var_31.as_str());
}
if let Some(var_32) = &input.content {
object.key("Content").string(var_32.as_str());
}
if let Some(var_33) = &input.description {
object.key("Description").string(var_33.as_str());
}
if let Some(var_34) = &input.r#type {
object.key("Type").string(var_34.as_str());
}
Ok(())
}
Trait Implementations§
source§impl Ord for Type
impl Ord for Type
source§impl PartialOrd<Type> for Type
impl PartialOrd<Type> for Type
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 Type
impl StructuralEq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
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.