Skip to main content

PhaseLabel

Trait PhaseLabel 

Source
pub trait PhaseLabel:
    Clone
    + PartialEq
    + 'static {
    const ALL: &'static [Self];

    // Required methods
    fn label(&self) -> &str;
    fn unknown(raw: String) -> Self;

    // Provided methods
    fn parse(s: &str) -> Option<Self> { ... }
    fn canonical() -> Vec<&'static str> { ... }
}
Expand description

A lifecycle-phase enum that can be rendered as a metric label.

The single source of truth for a CRD’s phase labels: PhaseLabel::ALL enumerates every canonical variant and PhaseLabel::label is an exhaustive match. The controller’s kopiur_resource_phase gauge uses these to set the active phase to 1 and the rest to 0 (and to clear all on deletion), so both the label string and the reset set come from the enum itself rather than a stringly-typed table that can silently drift (ADR §5.5 type-safety thesis).

Every phase enum also carries an Unknown(String) decode-compat variant (see the crate-internal phase_serde! macro below). It is deliberately absent from PhaseLabel::ALL: ALL is the CRD schema’s admissible set and the metric label domain, whereas Unknown only ever comes back off the wire from a newer operator’s write. label() therefore returns &str, not &'static strUnknown echoes the stored string verbatim.

Required Associated Constants§

Source

const ALL: &'static [Self]

Every canonical variant, in declaration order. Never contains Unknown.

Required Methods§

Source

fn label(&self) -> &str

The stable metric/wire label string for this variant (exhaustive match); the Unknown arm echoes the stored value verbatim so a read-modify-write never mutates a phase this build does not understand.

Source

fn unknown(raw: String) -> Self

Build the decode-compat fallback for a non-canonical stored string. Implemented by the phase_serde! macro’s host enum.

Provided Methods§

Source

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

Parse a canonical label; None for anything else (including a value that would decode to Unknown). Derived from ALL + label() so a new variant is parseable the moment it is declared.

Source

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

The canonical label set, for the CRD schema enum and “valid values” messages. One definition, derived from ALL.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl PhaseLabel for ManualRunPhase

Source§

const ALL: &'static [Self]

Source§

impl PhaseLabel for ReplicationManualRunPhase

Source§

const ALL: &'static [Self]

Source§

impl PhaseLabel for RepositoryPhase

Source§

const ALL: &'static [Self]

Source§

impl PhaseLabel for RepositoryReplicationPhase

Source§

const ALL: &'static [Self]

Source§

impl PhaseLabel for RestoreClaimPhase

Source§

const ALL: &'static [Self]

Source§

impl PhaseLabel for RestorePhase

Source§

const ALL: &'static [Self]

Source§

impl PhaseLabel for SnapshotPhase

Source§

const ALL: &'static [Self]

Source§

impl PhaseLabel for SnapshotReplicationPhase

Source§

const ALL: &'static [Self]