Enum aws_sdk_amplifybackend::model::MfaMode
source · #[non_exhaustive]
pub enum MfaMode {
Off,
On,
Optional,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against MfaMode, 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 mfamode = unimplemented!();
match mfamode {
MfaMode::Off => { /* ... */ },
MfaMode::On => { /* ... */ },
MfaMode::Optional => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when mfamode represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant MfaMode::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
MfaMode::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 MfaMode::NewFeature is defined.
Specifically, when mfamode represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on MfaMode::NewFeature also yielding "NewFeature".
Explicitly matching on the Unknown variant should
be avoided for two reasons:
- The inner data
UnknownVariantValueis 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
Off
On
Optional
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl MfaMode
impl MfaMode
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
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955
pub fn serialize_structure_crate_model_create_backend_auth_mfa_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CreateBackendAuthMfaConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_141) = &input.mfa_mode {
object.key("MFAMode").string(var_141.as_str());
}
if let Some(var_142) = &input.settings {
#[allow(unused_mut)]
let mut object_143 = object.key("settings").start_object();
crate::json_ser::serialize_structure_crate_model_settings(&mut object_143, var_142)?;
object_143.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_create_backend_auth_o_auth_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CreateBackendAuthOAuthConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_144) = &input.domain_prefix {
object.key("domainPrefix").string(var_144.as_str());
}
if let Some(var_145) = &input.o_auth_grant_type {
object.key("oAuthGrantType").string(var_145.as_str());
}
if let Some(var_146) = &input.o_auth_scopes {
let mut array_147 = object.key("oAuthScopes").start_array();
for item_148 in var_146 {
{
array_147.value().string(item_148.as_str());
}
}
array_147.finish();
}
if let Some(var_149) = &input.redirect_sign_in_ur_is {
let mut array_150 = object.key("redirectSignInURIs").start_array();
for item_151 in var_149 {
{
array_150.value().string(item_151.as_str());
}
}
array_150.finish();
}
if let Some(var_152) = &input.redirect_sign_out_ur_is {
let mut array_153 = object.key("redirectSignOutURIs").start_array();
for item_154 in var_152 {
{
array_153.value().string(item_154.as_str());
}
}
array_153.finish();
}
if let Some(var_155) = &input.social_provider_settings {
#[allow(unused_mut)]
let mut object_156 = object.key("socialProviderSettings").start_object();
crate::json_ser::serialize_structure_crate_model_social_provider_settings(
&mut object_156,
var_155,
)?;
object_156.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_create_backend_auth_password_policy_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CreateBackendAuthPasswordPolicyConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_157) = &input.additional_constraints {
let mut array_158 = object.key("additionalConstraints").start_array();
for item_159 in var_157 {
{
array_158.value().string(item_159.as_str());
}
}
array_158.finish();
}
{
object.key("minimumLength").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::Float((input.minimum_length).into()),
);
}
Ok(())
}
pub fn serialize_structure_crate_model_create_backend_auth_verification_message_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CreateBackendAuthVerificationMessageConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_160) = &input.delivery_method {
object.key("deliveryMethod").string(var_160.as_str());
}
if let Some(var_161) = &input.email_settings {
#[allow(unused_mut)]
let mut object_162 = object.key("emailSettings").start_object();
crate::json_ser::serialize_structure_crate_model_email_settings(&mut object_162, var_161)?;
object_162.finish();
}
if let Some(var_163) = &input.sms_settings {
#[allow(unused_mut)]
let mut object_164 = object.key("smsSettings").start_object();
crate::json_ser::serialize_structure_crate_model_sms_settings(&mut object_164, var_163)?;
object_164.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_update_backend_auth_forgot_password_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::UpdateBackendAuthForgotPasswordConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_165) = &input.delivery_method {
object.key("deliveryMethod").string(var_165.as_str());
}
if let Some(var_166) = &input.email_settings {
#[allow(unused_mut)]
let mut object_167 = object.key("emailSettings").start_object();
crate::json_ser::serialize_structure_crate_model_email_settings(&mut object_167, var_166)?;
object_167.finish();
}
if let Some(var_168) = &input.sms_settings {
#[allow(unused_mut)]
let mut object_169 = object.key("smsSettings").start_object();
crate::json_ser::serialize_structure_crate_model_sms_settings(&mut object_169, var_168)?;
object_169.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_update_backend_auth_mfa_config(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::UpdateBackendAuthMfaConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_170) = &input.mfa_mode {
object.key("MFAMode").string(var_170.as_str());
}
if let Some(var_171) = &input.settings {
#[allow(unused_mut)]
let mut object_172 = object.key("settings").start_object();
crate::json_ser::serialize_structure_crate_model_settings(&mut object_172, var_171)?;
object_172.finish();
}
Ok(())
}Trait Implementations§
source§impl Ord for MfaMode
impl Ord for MfaMode
source§impl PartialOrd<MfaMode> for MfaMode
impl PartialOrd<MfaMode> for MfaMode
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 MfaMode
impl StructuralEq for MfaMode
impl StructuralPartialEq for MfaMode
Auto Trait Implementations§
impl RefUnwindSafe for MfaMode
impl Send for MfaMode
impl Sync for MfaMode
impl Unpin for MfaMode
impl UnwindSafe for MfaMode
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.