#[non_exhaustive]pub enum RestartPolicy {
RunOnce,
Restart {
max: u32,
base_delay: Duration,
},
}Expand description
Policy governing what happens when a supervised task completes or panics.
Used in TaskDescriptor to configure restart behaviour for a task.
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.
RunOnce
Task runs once; normal completion removes it from the registry.
Restart
Task is restarted only on panic, up to max times.
Normal completion (the future returns ()) does not trigger a restart.
The task is removed from the registry on normal exit.
A max of 0 means the task is monitored but never restarted —
a panic leaves the entry as Failed in the registry for observability.
Use RunOnce when you want the entry removed on completion.
Restart delays follow exponential backoff: the delay before attempt n
is base_delay * 2^(n-1), capped at MAX_RESTART_DELAY.
§Examples
use std::time::Duration;
use zeph_common::task_supervisor::RestartPolicy;
// Restart up to 3 times with exponential backoff starting at 1 s.
let policy = RestartPolicy::Restart { max: 3, base_delay: Duration::from_secs(1) };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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for RestartPolicy
Source§impl Debug for RestartPolicy
impl Debug for RestartPolicy
impl Eq for RestartPolicy
Source§impl PartialEq for RestartPolicy
impl PartialEq for RestartPolicy
Source§fn eq(&self, other: &RestartPolicy) -> bool
fn eq(&self, other: &RestartPolicy) -> bool
Tests for
self and other values to be equal, and is used by ==.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