pub enum TaskState {
Pending,
Received,
Reserved,
Running,
Retrying(u32),
Succeeded(Vec<u8>),
Failed(String),
Revoked,
Rejected,
Custom {
name: String,
metadata: Option<Vec<u8>>,
},
}Expand description
Task state enumeration with strict state machine transitions
Variants§
Pending
Task is queued but not yet picked up by a worker
Received
Task has been received by a worker
Reserved
Task has been reserved by a worker but not yet executed
Running
Task is currently being executed
Retrying(u32)
Task is being retried (includes retry count)
Succeeded(Vec<u8>)
Task completed successfully with result
Failed(String)
Task failed with error message
Revoked
Task has been revoked
Rejected
Task has been rejected
Custom
Custom user-defined state with optional metadata
Implementations§
Source§impl TaskState
impl TaskState
Sourcepub const fn is_terminal(&self) -> bool
pub const fn is_terminal(&self) -> bool
Check if the task is in a terminal state
Sourcepub fn custom_with_metadata(name: impl Into<String>, metadata: Vec<u8>) -> Self
pub fn custom_with_metadata(name: impl Into<String>, metadata: Vec<u8>) -> Self
Create a custom state with name and JSON metadata
Sourcepub fn custom_name(&self) -> Option<&str>
pub fn custom_name(&self) -> Option<&str>
Get the custom state name if this is a custom state
Sourcepub fn custom_metadata(&self) -> Option<&[u8]>
pub fn custom_metadata(&self) -> Option<&[u8]>
Get the custom state metadata if this is a custom state with metadata
Sourcepub const fn is_revoked(&self) -> bool
pub const fn is_revoked(&self) -> bool
Check if the task is revoked
Sourcepub const fn is_rejected(&self) -> bool
pub const fn is_rejected(&self) -> bool
Check if the task is rejected
Sourcepub const fn is_received(&self) -> bool
pub const fn is_received(&self) -> bool
Check if the task is received
Sourcepub const fn retry_count(&self) -> u32
pub const fn retry_count(&self) -> u32
Get the retry count
Sourcepub const fn is_pending(&self) -> bool
pub const fn is_pending(&self) -> bool
Check if the task is pending
Sourcepub const fn is_reserved(&self) -> bool
pub const fn is_reserved(&self) -> bool
Check if the task is reserved
Sourcepub const fn is_running(&self) -> bool
pub const fn is_running(&self) -> bool
Check if the task is running
Sourcepub const fn is_retrying(&self) -> bool
pub const fn is_retrying(&self) -> bool
Check if the task is retrying
Sourcepub const fn is_succeeded(&self) -> bool
pub const fn is_succeeded(&self) -> bool
Check if the task succeeded
Sourcepub fn success_result(&self) -> Option<&[u8]>
pub fn success_result(&self) -> Option<&[u8]>
Get the success result if the task succeeded
Sourcepub fn error_message(&self) -> Option<&str>
pub fn error_message(&self) -> Option<&str>
Get the error message if the task failed