Enum aws_sdk_textract::model::FeatureType
source · #[non_exhaustive]
pub enum FeatureType {
Forms,
Queries,
Tables,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against FeatureType
, 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 featuretype = unimplemented!();
match featuretype {
FeatureType::Forms => { /* ... */ },
FeatureType::Queries => { /* ... */ },
FeatureType::Tables => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when featuretype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant FeatureType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
FeatureType::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 FeatureType::NewFeature
is defined.
Specifically, when featuretype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on FeatureType::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
Forms
Queries
Tables
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl FeatureType
impl FeatureType
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
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
pub fn serialize_structure_crate_input_analyze_document_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::AnalyzeDocumentInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_1) = &input.document {
#[allow(unused_mut)]
let mut object_2 = object.key("Document").start_object();
crate::json_ser::serialize_structure_crate_model_document(&mut object_2, var_1)?;
object_2.finish();
}
if let Some(var_3) = &input.feature_types {
let mut array_4 = object.key("FeatureTypes").start_array();
for item_5 in var_3 {
{
array_4.value().string(item_5.as_str());
}
}
array_4.finish();
}
if let Some(var_6) = &input.human_loop_config {
#[allow(unused_mut)]
let mut object_7 = object.key("HumanLoopConfig").start_object();
crate::json_ser::serialize_structure_crate_model_human_loop_config(&mut object_7, var_6)?;
object_7.finish();
}
if let Some(var_8) = &input.queries_config {
#[allow(unused_mut)]
let mut object_9 = object.key("QueriesConfig").start_object();
crate::json_ser::serialize_structure_crate_model_queries_config(&mut object_9, var_8)?;
object_9.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_analyze_expense_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::AnalyzeExpenseInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_10) = &input.document {
#[allow(unused_mut)]
let mut object_11 = object.key("Document").start_object();
crate::json_ser::serialize_structure_crate_model_document(&mut object_11, var_10)?;
object_11.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_analyze_id_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::AnalyzeIdInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_12) = &input.document_pages {
let mut array_13 = object.key("DocumentPages").start_array();
for item_14 in var_12 {
{
#[allow(unused_mut)]
let mut object_15 = array_13.value().start_object();
crate::json_ser::serialize_structure_crate_model_document(&mut object_15, item_14)?;
object_15.finish();
}
}
array_13.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_detect_document_text_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::DetectDocumentTextInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_16) = &input.document {
#[allow(unused_mut)]
let mut object_17 = object.key("Document").start_object();
crate::json_ser::serialize_structure_crate_model_document(&mut object_17, var_16)?;
object_17.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_get_document_analysis_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::GetDocumentAnalysisInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_18) = &input.job_id {
object.key("JobId").string(var_18.as_str());
}
if let Some(var_19) = &input.max_results {
object.key("MaxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_19).into()),
);
}
if let Some(var_20) = &input.next_token {
object.key("NextToken").string(var_20.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_get_document_text_detection_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::GetDocumentTextDetectionInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_21) = &input.job_id {
object.key("JobId").string(var_21.as_str());
}
if let Some(var_22) = &input.max_results {
object.key("MaxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_22).into()),
);
}
if let Some(var_23) = &input.next_token {
object.key("NextToken").string(var_23.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_get_expense_analysis_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::GetExpenseAnalysisInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_24) = &input.job_id {
object.key("JobId").string(var_24.as_str());
}
if let Some(var_25) = &input.max_results {
object.key("MaxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_25).into()),
);
}
if let Some(var_26) = &input.next_token {
object.key("NextToken").string(var_26.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_start_document_analysis_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::StartDocumentAnalysisInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_27) = &input.document_location {
#[allow(unused_mut)]
let mut object_28 = object.key("DocumentLocation").start_object();
crate::json_ser::serialize_structure_crate_model_document_location(&mut object_28, var_27)?;
object_28.finish();
}
if let Some(var_29) = &input.feature_types {
let mut array_30 = object.key("FeatureTypes").start_array();
for item_31 in var_29 {
{
array_30.value().string(item_31.as_str());
}
}
array_30.finish();
}
if let Some(var_32) = &input.client_request_token {
object.key("ClientRequestToken").string(var_32.as_str());
}
if let Some(var_33) = &input.job_tag {
object.key("JobTag").string(var_33.as_str());
}
if let Some(var_34) = &input.notification_channel {
#[allow(unused_mut)]
let mut object_35 = object.key("NotificationChannel").start_object();
crate::json_ser::serialize_structure_crate_model_notification_channel(
&mut object_35,
var_34,
)?;
object_35.finish();
}
if let Some(var_36) = &input.output_config {
#[allow(unused_mut)]
let mut object_37 = object.key("OutputConfig").start_object();
crate::json_ser::serialize_structure_crate_model_output_config(&mut object_37, var_36)?;
object_37.finish();
}
if let Some(var_38) = &input.kms_key_id {
object.key("KMSKeyId").string(var_38.as_str());
}
if let Some(var_39) = &input.queries_config {
#[allow(unused_mut)]
let mut object_40 = object.key("QueriesConfig").start_object();
crate::json_ser::serialize_structure_crate_model_queries_config(&mut object_40, var_39)?;
object_40.finish();
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for FeatureType
impl AsRef<str> for FeatureType
source§impl Clone for FeatureType
impl Clone for FeatureType
source§fn clone(&self) -> FeatureType
fn clone(&self) -> FeatureType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FeatureType
impl Debug for FeatureType
source§impl From<&str> for FeatureType
impl From<&str> for FeatureType
source§impl FromStr for FeatureType
impl FromStr for FeatureType
source§impl Hash for FeatureType
impl Hash for FeatureType
source§impl Ord for FeatureType
impl Ord for FeatureType
source§fn cmp(&self, other: &FeatureType) -> Ordering
fn cmp(&self, other: &FeatureType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<FeatureType> for FeatureType
impl PartialEq<FeatureType> for FeatureType
source§fn eq(&self, other: &FeatureType) -> bool
fn eq(&self, other: &FeatureType) -> bool
source§impl PartialOrd<FeatureType> for FeatureType
impl PartialOrd<FeatureType> for FeatureType
source§fn partial_cmp(&self, other: &FeatureType) -> Option<Ordering>
fn partial_cmp(&self, other: &FeatureType) -> 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 FeatureType
impl StructuralEq for FeatureType
impl StructuralPartialEq for FeatureType
Auto Trait Implementations§
impl RefUnwindSafe for FeatureType
impl Send for FeatureType
impl Sync for FeatureType
impl Unpin for FeatureType
impl UnwindSafe for FeatureType
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.