Skip to main content

RestartPolicy

Enum RestartPolicy 

Source
pub enum RestartPolicy {
    Permanent,
    Temporary,
    Transient,
}
Expand description

Per-child restart policy.

Permanent / Temporary / Transient match Erlang/OTP semantics 1:1.

Variants§

§

Permanent

Always restart the child, regardless of how it died. Used for long-running services that must always be up.

§

Temporary

Never restart. Used for one-shot work whose completion is itself the success signal (oneShot triggers map here).

§

Transient

Restart only when the child died abnormally (non-zero exit or unhandled exception). A clean exit completes the child.

Implementations§

Source§

impl RestartPolicy

Source

pub const fn discriminant(&self) -> &'static str

Stable variant discriminant — auto-generated by #[derive(Discriminant)]. The string IS the wire identifier for metrics labels / audit-log tags / rate-limit keys; renaming an existing variant is a breaking change.

Source§

impl RestartPolicy

Source

pub const fn is_permanent(&self) -> bool

Source

pub const fn is_temporary(&self) -> bool

Source

pub const fn is_transient(&self) -> bool

Source§

impl RestartPolicy

Source

pub const ALL: &'static [Self]

Exhaustive iteration surface for every consumer that walks the closed three-arm RestartPolicy discriminator set (the future M4 mesh.pleme.io/v1alpha1/Supervisor CR materializer’s per-child admission-webhook rejection body naming the accepted- :restart list, a future feira supervisor --restart … CLI arg-parse’s “did you mean” hint via a Self::from_wire-scan over the slice, the future feira app graph per-child restart column, any future round-trip fuzz harness that sweeps every arm). A future arm addition (an OTP-intrinsic fourth arm the theory ABSORPTION-ROADMAP might reach for once the three canonical OTP restart policies stop covering the substrate’s discovered load-shape) extends this slice as one edit and every consumer picks up the new entry by construction; the compiler-checked exhaustiveness on the sibling method match arms (Self::as_str / Self::from_wire) is the build-time guarantee that no arm forgets to grow.

Peer of the sibling closed-set typed enums’ RestartStrategy::ALL (4eec29c) / crate::CaixaKind::ALL (6b1f4fb) / crate::aplicacao::PlacementStrategy::ALL (18c7342) / crate::aplicacao::RateLimitUnit::ALL (6bce03d) / crate::dep::DepList::ALL (45ee563) exhaustive-iteration surfaces — the sixth (and the third and final M2 OTP-shape) closed-set typed enum on the caixa surface to converge onto the same one-canonical-arm-list-per-enum discipline. Sibling axis to the peer RestartStrategy::ALL on the per-supervisor sibling-restart-strategy axis; this closes the per-child restart-decision-policy axis on the same M2 :supervisor slot.

Source

pub const fn as_str(self) -> &'static str

Canonical PascalCase discriminator scalar this variant serializes as under crate::render::SUPERVISOR_CHILD_KEY_RESTART. The three arms return the paired crate::render::SUPERVISOR_CHILD_RESTART_PERMANENT / crate::render::SUPERVISOR_CHILD_RESTART_TEMPORARY / crate::render::SUPERVISOR_CHILD_RESTART_TRANSIENT lifted constants so every substrate consumer that dispatches on the per-child restart-decision policy (the future wasm-operator’s per-child post-exit restart-decision branch, the future M4 mesh.pleme.io/v1alpha1/Supervisor CR materializer’s admission-time enum-arm bind, the caixa-operator’s hierarchical reconciliation scheduler’s per-child-policy fan-out) reads the same byte-string the Serialize derive emits — the pin test in [tests::restart_policy_variants_serialize_to_lifted_scalar_values] asserts the two paths agree, peer of the M2 RestartStrategy::as_str (09ffb2d) on the sibling per-supervisor sibling-restart-strategy axis and the M3 crate::aplicacao::PlacementStrategy::as_str (cc8f749) on the per-Aplicacao distribution-strategy axis — the third of three OTP-shaped closed-enum discriminator axes on the caixa typed surface to converge onto the same three-path-convergence (Serialize derive → as_str helper → lifted constant) drift-detection posture.

Source

pub fn from_wire(s: &str) -> Option<Self>

Substrate-canonical reverse projection on the :children :restart closed-set axis — parses the PascalCase discriminator scalar back to the typed variant, or None when s is outside the closed-set arm-string set Self::as_str emits. Dispatches on the same lifted crate::render::SUPERVISOR_CHILD_RESTART_PERMANENT / crate::render::SUPERVISOR_CHILD_RESTART_TEMPORARY / crate::render::SUPERVISOR_CHILD_RESTART_TRANSIENT constants the Self::as_str emitter walks, so the parse and emit halves of the round-trip migrate through one caixa-core edit on any future arm addition.

Prior to this lift the substrate carried only the forward Self → &str projection on the OTP per-child restart-policy axis (the Self::as_str emitter, the std::fmt::Display impl routed through it, the Serialize derive that emits the same byte-string under crate::render::SUPERVISOR_CHILD_KEY_RESTART) plus the kebab-case dispatcher-catalog identity via Self::discriminant — every non-serde consumer that wanted to parse a wire-form PascalCase policy scalar had to re-inline a three-arm match s { "Permanent" => …, "Temporary" => …, "Transient" => …, _ => … } cascade that expressed no compile-time link back to the typed variant’s canonical lifted constant. A future variant rename or per-arm serde-attribute drift would silently split the wire byte-string one non-serde consumer parsed from the one the emitter wrote, with the failure surfacing at the operator’s reconcile posture (a :temporary oneShot child being restarted on clean exit, treating the successful-completion signal as failure and re-running the completion-terminal one-shot indefinitely; a :transient child that clean-exited being restarted, masking the clean-completion contract) far from the rebrand commit and with no field naming the drift.

Distinct axis from the std::str::FromStr impl the gen_platform::FromStrKind derive already installs on this enum by design, not by drift: FromStr parses the kebab-case dispatcher-catalog identity ("permanent" / "temporary" / "transient" — the inverse of Self::discriminant), while this method inverts the PascalCase wire byte-string Self::as_str emits. The two-axis split lets the dispatcher- catalog identity live in kebab-case (where every peer catalog identifier already lives) without forcing a wire-format rename on the tatara-lisp author surface (:restart Permanent, PascalCase) — the same two-axis distinction the sibling RestartStrategy::from_wire (4eec29c) / crate::CaixaKind::from_wire (2aa6d23) / crate::aplicacao::PlacementStrategy::from_wire (18c7342) carry on their peer closed-set typed-enum wire round-trips.

Same closed-set-reverse-projection discipline the sibling RestartStrategy::from_wire (4eec29c) / crate::CaixaKind::from_wire (2aa6d23) / crate::aplicacao::PlacementStrategy::from_wire (18c7342) / crate::aplicacao::RateLimitUnit::from_suffix typed enums carry on the peer wire-side str → Self axes — extended onto the M2 OTP-shape per-child restart-policy closed-set axis, the sixth substrate-side closed-set typed enum (and the third and final OTP-shape closed-enum discriminator axis) to converge on the two-way str ↔ Self round-trip. Method-named from_wire (not from_str) to match the peer RestartStrategy::from_wire shape verbatim and side-step the std::str::FromStr impl the derive already installs on the sibling kebab-case axis. Returns Option<Self> (rather than Result<Self, _>) to match the peer shapes: the caller picks the diagnostic form appropriate for its use site.

Trait Implementations§

Source§

impl Clone for RestartPolicy

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Copy for RestartPolicy

Source§

impl Debug for RestartPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RestartPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RestartPolicy

Source§

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 Display for RestartPolicy

std::fmt::Display routed through RestartPolicy::as_str, so the pretty-printed byte-string every consumer that formats the policy as user-facing text lands on (the future wasm-operator’s per-child post-exit restart-decision diagnostic line, the future feira app graph per-child restart column, the future M4 mesh.pleme.io/v1alpha1/Supervisor CR materializer’s per-child admission-webhook rejection body) reaches for the same lifted crate::render::SUPERVISOR_CHILD_RESTART_PERMANENT / crate::render::SUPERVISOR_CHILD_RESTART_TEMPORARY / crate::render::SUPERVISOR_CHILD_RESTART_TRANSIENT const the wire-format Serialize derive already emits under crate::render::SUPERVISOR_CHILD_KEY_RESTART and the RestartPolicy::as_str helper already returns.

Pre-convergence the two paths structurally disagreed — the #[derive(gen_platform::Discriminant)] + #[discriminant(also_display)] route (now retired here) sent std::fmt::Display through the gen-platform discriminant catalog string, which arrives kebab-case as "permanent" / "temporary" / "transient" on this three-arm enum (whose variant names each collapse to their own lowercase form under the kebab-case transform), while the wire format ran as PascalCase "Permanent" / "Temporary" / "Transient" through the un-renamed serde derive. Every consumer that formatted the policy for a diagnostic line, a graph column, or a rejection body under format!("{v}") therefore landed under a different byte-string than the wire format the operator’s per-child-policy dispatch keyed off — a silent split whose apply-time symptom (a format!("{v}")-carrying diagnostic quoting "permanent" while the wire scalar the operator probed was "Permanent") surfaced as a confused correlate at operator-log time far from the two-declaration site.

Routing Display through RestartPolicy::as_str closes the third path: every format!("{v}") call reaches the same lifted [crate::render::SUPERVISOR_CHILD_RESTART_*] const the wire format and the RestartPolicy::as_str helper route through — Debug (the compiler-derived variant name), Display (via as_str), and Serialize (via the un-renamed derive) all resolve to the same PascalCase byte-string per variant. A future variant rename or #[serde(rename_all = "kebab-case")] attribute reaches every path at exactly one place, structurally.

The dispatcher-catalog identity remains kebab-case — Self::discriminant (from #[derive(gen_platform::Discriminant)]) still returns "permanent" / "temporary" / "transient", and the fleet-wide [gen_platform::register_dispatcher!("caixa.restart-policy", …)] registration keys the catalog off the same kebab identity. The two naming worlds now live on separate typed methods (Display / as_str for the wire byte-string, discriminant for the catalog identity) rather than sharing one Display route that structurally disagrees with the wire format.

Pin tests [tests::restart_policy_display_routes_through_as_str_helper] and [tests::restart_policy_display_matches_serialized_wire_byte_string] assert the three paths agree byte-for-byte on every variant, so a future variant rename or per-arm serde attribute drift is a build error visible at caixa-core test time, not a silent per-consumer dispatch miss at apply / reconcile time.

Mirrors the M3 crate::aplicacao::PlacementStrategy Display impl (aplicacao.rs:2306) on the per-Aplicacao distribution-strategy axis and the sibling RestartStrategy Display impl on the per-supervisor sibling-restart-strategy axis — same three-path- convergence discipline, extended to close the third and final of three OTP-shaped closed-enum discriminator axes on the caixa typed surface.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RestartPolicy

Source§

impl FromStr for RestartPolicy

Source§

type Err = RestartPolicyParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for RestartPolicy

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RestartPolicy

Source§

fn eq(&self, other: &RestartPolicy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RestartPolicy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RestartPolicy

Source§

impl TypedDispatcher for RestartPolicy

Source§

fn variant_kinds() -> Vec<&'static str>

Kebab-case serde tags of every variant in declaration order. Used by substrate emitters (Nix helpers skeleton, Lisp catalog, coverage tests) to enumerate the variant universe.
Source§

fn variant_fields() -> Vec<(&'static str, Vec<&'static str>)>

Field names per variant, paired with the variant’s kebab-case tag. Used by substrate emitters to produce the matching inherit (variant) <fields> Nix patterns.
Source§

fn variant_count() -> usize

Total variant count. Convenience for coverage assertions.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.