#[non_exhaustive]
pub enum InputFormat {
    OneDocPerFile,
    OneDocPerLine,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against InputFormat, 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 inputformat = unimplemented!();
match inputformat {
    InputFormat::OneDocPerFile => { /* ... */ },
    InputFormat::OneDocPerLine => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

The above code demonstrates that when inputformat represents NewFeature, the execution path will lead to the second last match arm, even though the enum does not contain a variant InputFormat::NewFeature in the current version of SDK. The reason is that the variable other, created by the @ operator, is bound to InputFormat::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 InputFormat::NewFeature is defined. Specifically, when inputformat represents NewFeature, the execution path will hit the second last match arm as before by virtue of calling as_str on InputFormat::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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

OneDocPerFile

§

OneDocPerLine

§

Unknown(UnknownVariantValue)

Unknown contains new variants that have been added since this code was generated.

Implementations§

Returns the &str value of the enum member.

Examples found in repository?
src/model.rs (line 997)
996
997
998
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 2078)
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
pub fn serialize_structure_crate_model_input_data_config(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::InputDataConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_407) = &input.s3_uri {
        object.key("S3Uri").string(var_407.as_str());
    }
    if let Some(var_408) = &input.input_format {
        object.key("InputFormat").string(var_408.as_str());
    }
    if let Some(var_409) = &input.document_reader_config {
        #[allow(unused_mut)]
        let mut object_410 = object.key("DocumentReaderConfig").start_object();
        crate::json_ser::serialize_structure_crate_model_document_reader_config(
            &mut object_410,
            var_409,
        )?;
        object_410.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_output_data_config(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::OutputDataConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_411) = &input.s3_uri {
        object.key("S3Uri").string(var_411.as_str());
    }
    if let Some(var_412) = &input.kms_key_id {
        object.key("KmsKeyId").string(var_412.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_redaction_config(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::RedactionConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_413) = &input.pii_entity_types {
        let mut array_414 = object.key("PiiEntityTypes").start_array();
        for item_415 in var_413 {
            {
                array_414.value().string(item_415.as_str());
            }
        }
        array_414.finish();
    }
    if let Some(var_416) = &input.mask_mode {
        object.key("MaskMode").string(var_416.as_str());
    }
    if let Some(var_417) = &input.mask_character {
        object.key("MaskCharacter").string(var_417.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_augmented_manifests_list_item(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::AugmentedManifestsListItem,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_418) = &input.s3_uri {
        object.key("S3Uri").string(var_418.as_str());
    }
    if let Some(var_419) = &input.split {
        object.key("Split").string(var_419.as_str());
    }
    if let Some(var_420) = &input.attribute_names {
        let mut array_421 = object.key("AttributeNames").start_array();
        for item_422 in var_420 {
            {
                array_421.value().string(item_422.as_str());
            }
        }
        array_421.finish();
    }
    if let Some(var_423) = &input.annotation_data_s3_uri {
        object.key("AnnotationDataS3Uri").string(var_423.as_str());
    }
    if let Some(var_424) = &input.source_documents_s3_uri {
        object.key("SourceDocumentsS3Uri").string(var_424.as_str());
    }
    if let Some(var_425) = &input.document_type {
        object.key("DocumentType").string(var_425.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_entity_types_list_item(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::EntityTypesListItem,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_426) = &input.r#type {
        object.key("Type").string(var_426.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_entity_recognizer_documents(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::EntityRecognizerDocuments,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_427) = &input.s3_uri {
        object.key("S3Uri").string(var_427.as_str());
    }
    if let Some(var_428) = &input.test_s3_uri {
        object.key("TestS3Uri").string(var_428.as_str());
    }
    if let Some(var_429) = &input.input_format {
        object.key("InputFormat").string(var_429.as_str());
    }
    Ok(())
}

Returns all the &str values of the enum members.

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more