#[non_exhaustive]
pub enum OperationStatus {
Failed,
InProgress,
Pending,
Success,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against OperationStatus, 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 operationstatus = unimplemented!();
match operationstatus {
OperationStatus::Failed => { /* ... */ },
OperationStatus::InProgress => { /* ... */ },
OperationStatus::Pending => { /* ... */ },
OperationStatus::Success => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when operationstatus represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant OperationStatus::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
OperationStatus::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 OperationStatus::NewFeature is defined.
Specifically, when operationstatus represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on OperationStatus::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
Failed
InProgress
Pending
Success
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl OperationStatus
impl OperationStatus
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
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909
pub fn serialize_operation_crate_operation_record_handler_progress(
input: &crate::input::RecordHandlerProgressInput,
) -> Result<aws_smithy_http::body::SdkBody, aws_smithy_http::operation::error::SerializationError> {
let mut out = String::new();
#[allow(unused_mut)]
let mut writer =
aws_smithy_query::QueryWriter::new(&mut out, "RecordHandlerProgress", "2010-05-15");
#[allow(unused_mut)]
let mut scope_527 = writer.prefix("BearerToken");
if let Some(var_528) = &input.bearer_token {
scope_527.string(var_528);
}
#[allow(unused_mut)]
let mut scope_529 = writer.prefix("OperationStatus");
if let Some(var_530) = &input.operation_status {
scope_529.string(var_530.as_str());
}
#[allow(unused_mut)]
let mut scope_531 = writer.prefix("CurrentOperationStatus");
if let Some(var_532) = &input.current_operation_status {
scope_531.string(var_532.as_str());
}
#[allow(unused_mut)]
let mut scope_533 = writer.prefix("StatusMessage");
if let Some(var_534) = &input.status_message {
scope_533.string(var_534);
}
#[allow(unused_mut)]
let mut scope_535 = writer.prefix("ErrorCode");
if let Some(var_536) = &input.error_code {
scope_535.string(var_536.as_str());
}
#[allow(unused_mut)]
let mut scope_537 = writer.prefix("ResourceModel");
if let Some(var_538) = &input.resource_model {
scope_537.string(var_538);
}
#[allow(unused_mut)]
let mut scope_539 = writer.prefix("ClientRequestToken");
if let Some(var_540) = &input.client_request_token {
scope_539.string(var_540);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}Trait Implementations§
source§impl AsRef<str> for OperationStatus
impl AsRef<str> for OperationStatus
source§impl Clone for OperationStatus
impl Clone for OperationStatus
source§fn clone(&self) -> OperationStatus
fn clone(&self) -> OperationStatus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for OperationStatus
impl Debug for OperationStatus
source§impl From<&str> for OperationStatus
impl From<&str> for OperationStatus
source§impl FromStr for OperationStatus
impl FromStr for OperationStatus
source§impl Hash for OperationStatus
impl Hash for OperationStatus
source§impl Ord for OperationStatus
impl Ord for OperationStatus
source§fn cmp(&self, other: &OperationStatus) -> Ordering
fn cmp(&self, other: &OperationStatus) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<OperationStatus> for OperationStatus
impl PartialEq<OperationStatus> for OperationStatus
source§fn eq(&self, other: &OperationStatus) -> bool
fn eq(&self, other: &OperationStatus) -> bool
source§impl PartialOrd<OperationStatus> for OperationStatus
impl PartialOrd<OperationStatus> for OperationStatus
source§fn partial_cmp(&self, other: &OperationStatus) -> Option<Ordering>
fn partial_cmp(&self, other: &OperationStatus) -> 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 OperationStatus
impl StructuralEq for OperationStatus
impl StructuralPartialEq for OperationStatus
Auto Trait Implementations§
impl RefUnwindSafe for OperationStatus
impl Send for OperationStatus
impl Sync for OperationStatus
impl Unpin for OperationStatus
impl UnwindSafe for OperationStatus
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.