#[non_exhaustive]pub enum RestartPolicy {
Never,
OnFailure,
Always {
interval_ms: Option<u64>,
},
}Expand description
Determines whether a task should be automatically restarted after completion or failure.
| Variant | Behaviour |
|---|---|
Never | Do not restart under any circumstances |
OnFailure | Restart only when the task ends with an error |
Always | Restart unconditionally (immediate or periodic via interval) |
Always { interval_ms: None } restarts immediately;
Always { interval_ms: Some(N) } waits N ms between runs (periodic task).
Cancellation (via controller or shutdown) is not treated as failure and will not trigger a restart.
§Also
BackoffPolicydelay between restart attempts.TaskSpeccarriesrestartas a field.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Never
Never restart the task.
OnFailure
Restart the task only if it failed (non-zero exit, error, panic, etc.).
Always
Always restart after completion.
interval_ms: None— restart immediately after the previous run completes (tight loop tempered only by [BackoffPolicy] on failure).interval_ms: Some(n)— waitnmilliseconds between runs (periodic task).Some(0)is treated as immediate and is semantically identical toNone; preferNonefor clarity.
Implementations§
Trait Implementations§
Source§impl Clone for RestartPolicy
impl Clone for RestartPolicy
Source§fn clone(&self) -> RestartPolicy
fn clone(&self) -> RestartPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RestartPolicy
impl Debug for RestartPolicy
Source§impl Default for RestartPolicy
impl Default for RestartPolicy
Source§fn default() -> RestartPolicy
fn default() -> RestartPolicy
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for RestartPolicy
impl<'de> Deserialize<'de> for RestartPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromStr for RestartPolicy
impl FromStr for RestartPolicy
Source§type Err = ModelError
type Err = ModelError
The associated error which can be returned from parsing.
Source§impl PartialEq for RestartPolicy
impl PartialEq for RestartPolicy
Source§impl Serialize for RestartPolicy
impl Serialize for RestartPolicy
impl Copy for RestartPolicy
impl Eq for RestartPolicy
impl StructuralPartialEq for RestartPolicy
Auto Trait Implementations§
impl Freeze for RestartPolicy
impl RefUnwindSafe for RestartPolicy
impl Send for RestartPolicy
impl Sync for RestartPolicy
impl Unpin for RestartPolicy
impl UnsafeUnpin for RestartPolicy
impl UnwindSafe for RestartPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more