aws-sdk-appconfigcloudextension 1.0.0

AWS SDK for AWS AppConfig Cloud Extension
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// The constraint a value failed, named for the Smithy trait or rule that declares it, with what it allows.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub enum Constraint {
    /// The value is not one of the enum's values.
    Enum(crate::types::EnumConstraint),
    /// The value's length is outside @length.
    Length(crate::types::LengthConstraint),
    /// The value doesn't match @pattern.
    Pattern(crate::types::PatternConstraint),
    /// The value is outside @range.
    Range(crate::types::RangeConstraint),
    /// The member is @required and missing. Always true when set.
    Required(bool),
    /// The value is not the member's type.
    Type(crate::types::TypeConstraint),
    /// The union sets no member or more than one. Always true when set.
    Union(bool),
    /// The `Unknown` variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
    /// An unknown enum variant
    ///
    /// _Note: If you encounter this error, consider upgrading your SDK to the latest version._
    /// The `Unknown` variant represents cases where the server sent a value that wasn't recognized
    /// by the client. This can happen when the server adds new functionality, but the client has not been updated.
    /// To investigate this, consider turning on debug logging to print the raw HTTP response.
    #[non_exhaustive]
    Unknown,
}
impl Constraint {
    /// Tries to convert the enum instance into [`Enum`](crate::types::Constraint::Enum), extracting the inner [`EnumConstraint`](crate::types::EnumConstraint).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_enum(&self) -> ::std::result::Result<&crate::types::EnumConstraint, &Self> {
        if let Constraint::Enum(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`Enum`](crate::types::Constraint::Enum).
    pub fn is_enum(&self) -> bool {
        self.as_enum().is_ok()
    }
    /// Tries to convert the enum instance into [`Length`](crate::types::Constraint::Length), extracting the inner [`LengthConstraint`](crate::types::LengthConstraint).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_length(&self) -> ::std::result::Result<&crate::types::LengthConstraint, &Self> {
        if let Constraint::Length(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`Length`](crate::types::Constraint::Length).
    pub fn is_length(&self) -> bool {
        self.as_length().is_ok()
    }
    /// Tries to convert the enum instance into [`Pattern`](crate::types::Constraint::Pattern), extracting the inner [`PatternConstraint`](crate::types::PatternConstraint).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_pattern(&self) -> ::std::result::Result<&crate::types::PatternConstraint, &Self> {
        if let Constraint::Pattern(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`Pattern`](crate::types::Constraint::Pattern).
    pub fn is_pattern(&self) -> bool {
        self.as_pattern().is_ok()
    }
    /// Tries to convert the enum instance into [`Range`](crate::types::Constraint::Range), extracting the inner [`RangeConstraint`](crate::types::RangeConstraint).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_range(&self) -> ::std::result::Result<&crate::types::RangeConstraint, &Self> {
        if let Constraint::Range(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`Range`](crate::types::Constraint::Range).
    pub fn is_range(&self) -> bool {
        self.as_range().is_ok()
    }
    /// Tries to convert the enum instance into [`Required`](crate::types::Constraint::Required), extracting the inner [`bool`](bool).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_required(&self) -> ::std::result::Result<&bool, &Self> {
        if let Constraint::Required(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`Required`](crate::types::Constraint::Required).
    pub fn is_required(&self) -> bool {
        self.as_required().is_ok()
    }
    /// Tries to convert the enum instance into [`Type`](crate::types::Constraint::Type), extracting the inner [`TypeConstraint`](crate::types::TypeConstraint).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_type(&self) -> ::std::result::Result<&crate::types::TypeConstraint, &Self> {
        if let Constraint::Type(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`Type`](crate::types::Constraint::Type).
    pub fn is_type(&self) -> bool {
        self.as_type().is_ok()
    }
    /// Tries to convert the enum instance into [`Union`](crate::types::Constraint::Union), extracting the inner [`bool`](bool).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_union(&self) -> ::std::result::Result<&bool, &Self> {
        if let Constraint::Union(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`Union`](crate::types::Constraint::Union).
    pub fn is_union(&self) -> bool {
        self.as_union().is_ok()
    }
    /// Returns true if the enum instance is the `Unknown` variant.
    pub fn is_unknown(&self) -> bool {
        matches!(self, Self::Unknown)
    }
}