1 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
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>An object that represents the method and value to match with the header value sent in a request. Specify one match method.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub enum HeaderMatchMethod {
/// <p>The value sent by the client must match the specified value exactly.</p>
Exact(::std::string::String),
/// <p>The value sent by the client must begin with the specified characters.</p>
Prefix(::std::string::String),
/// <p>An object that represents the range of values to match on.</p>
Range(crate::types::MatchRange),
/// <p>The value sent by the client must include the specified characters.</p>
Regex(::std::string::String),
/// <p>The value sent by the client must end with the specified characters.</p>
Suffix(::std::string::String),
/// 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 HeaderMatchMethod {
/// Tries to convert the enum instance into [`Exact`](crate::types::HeaderMatchMethod::Exact), extracting the inner [`String`](::std::string::String).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_exact(&self) -> ::std::result::Result<&::std::string::String, &Self> {
if let HeaderMatchMethod::Exact(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Exact`](crate::types::HeaderMatchMethod::Exact).
pub fn is_exact(&self) -> bool {
self.as_exact().is_ok()
}
/// Tries to convert the enum instance into [`Prefix`](crate::types::HeaderMatchMethod::Prefix), extracting the inner [`String`](::std::string::String).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_prefix(&self) -> ::std::result::Result<&::std::string::String, &Self> {
if let HeaderMatchMethod::Prefix(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Prefix`](crate::types::HeaderMatchMethod::Prefix).
pub fn is_prefix(&self) -> bool {
self.as_prefix().is_ok()
}
/// Tries to convert the enum instance into [`Range`](crate::types::HeaderMatchMethod::Range), extracting the inner [`MatchRange`](crate::types::MatchRange).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_range(&self) -> ::std::result::Result<&crate::types::MatchRange, &Self> {
if let HeaderMatchMethod::Range(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Range`](crate::types::HeaderMatchMethod::Range).
pub fn is_range(&self) -> bool {
self.as_range().is_ok()
}
/// Tries to convert the enum instance into [`Regex`](crate::types::HeaderMatchMethod::Regex), extracting the inner [`String`](::std::string::String).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_regex(&self) -> ::std::result::Result<&::std::string::String, &Self> {
if let HeaderMatchMethod::Regex(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Regex`](crate::types::HeaderMatchMethod::Regex).
pub fn is_regex(&self) -> bool {
self.as_regex().is_ok()
}
/// Tries to convert the enum instance into [`Suffix`](crate::types::HeaderMatchMethod::Suffix), extracting the inner [`String`](::std::string::String).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_suffix(&self) -> ::std::result::Result<&::std::string::String, &Self> {
if let HeaderMatchMethod::Suffix(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Suffix`](crate::types::HeaderMatchMethod::Suffix).
pub fn is_suffix(&self) -> bool {
self.as_suffix().is_ok()
}
/// Returns true if the enum instance is the `Unknown` variant.
pub fn is_unknown(&self) -> bool {
matches!(self, Self::Unknown)
}
}