Enum aws_sdk_batch::model::JobStatus
source · #[non_exhaustive]
pub enum JobStatus {
Failed,
Pending,
Runnable,
Running,
Starting,
Submitted,
Succeeded,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against JobStatus
, 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 jobstatus = unimplemented!();
match jobstatus {
JobStatus::Failed => { /* ... */ },
JobStatus::Pending => { /* ... */ },
JobStatus::Runnable => { /* ... */ },
JobStatus::Running => { /* ... */ },
JobStatus::Starting => { /* ... */ },
JobStatus::Submitted => { /* ... */ },
JobStatus::Succeeded => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when jobstatus
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant JobStatus::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
JobStatus::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 JobStatus::NewFeature
is defined.
Specifically, when jobstatus
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on JobStatus::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
Failed
Pending
Runnable
Running
Starting
Submitted
Succeeded
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl JobStatus
impl JobStatus
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
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
pub fn serialize_structure_crate_input_list_jobs_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::ListJobsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_60) = &input.array_job_id {
object.key("arrayJobId").string(var_60.as_str());
}
if let Some(var_61) = &input.filters {
let mut array_62 = object.key("filters").start_array();
for item_63 in var_61 {
{
#[allow(unused_mut)]
let mut object_64 = array_62.value().start_object();
crate::json_ser::serialize_structure_crate_model_key_values_pair(
&mut object_64,
item_63,
)?;
object_64.finish();
}
}
array_62.finish();
}
if let Some(var_65) = &input.job_queue {
object.key("jobQueue").string(var_65.as_str());
}
if let Some(var_66) = &input.job_status {
object.key("jobStatus").string(var_66.as_str());
}
if let Some(var_67) = &input.max_results {
object.key("maxResults").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_67).into()),
);
}
if let Some(var_68) = &input.multi_node_job_id {
object.key("multiNodeJobId").string(var_68.as_str());
}
if let Some(var_69) = &input.next_token {
object.key("nextToken").string(var_69.as_str());
}
Ok(())
}
Trait Implementations§
source§impl Ord for JobStatus
impl Ord for JobStatus
source§impl PartialOrd<JobStatus> for JobStatus
impl PartialOrd<JobStatus> for JobStatus
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 JobStatus
impl StructuralEq for JobStatus
impl StructuralPartialEq for JobStatus
Auto Trait Implementations§
impl RefUnwindSafe for JobStatus
impl Send for JobStatus
impl Sync for JobStatus
impl Unpin for JobStatus
impl UnwindSafe for JobStatus
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.