Skip to main content

DurationUnitError

Enum DurationUnitError 

Source
pub enum DurationUnitError {
    Overflow {
        multiplier: u64,
    },
    UnknownUnit,
}
Expand description

Typed outcome of dispatching a validated integer magnitude through the shared {ms, s, "", m, h} → Duration unit table.

Returned by duration_from_integer_magnitude_and_unit so each typed-duration codec (limits::parse_duration backing :limits :wall-clock, supervisor::duration_codec::parse backing the shared :supervisor :restart-window / :politicas :timeout / :politicas :circuit-breaker :window duration slots) maps the axis- agnostic outcome onto its own axis-specific error variant. The closed-set discriminants (Overflow / UnknownUnit) partition the two diagnostic classes each caller distinguishes today:

  • Overflow { multiplier } — the accepted unit’s num × multiplier conversion overflows u64::MAX. multiplier is the same literal the pre-lift arm’s diagnostic named verbatim (60 for "m", 3600 for "h"), so each caller reconstructs the exact pre-lift wording ("…overflows u64 (magnitude × 60 > 2^64-1)") from the discriminant + its own magnitude/unit locals. The "ms" / "s" / "" arms cannot overflow (every u64 maps to a representable Duration via from_millis / from_secs) so no multiplier variant carries those units.
  • UnknownUnit — the trimmed unit suffix is not in the accepted set {"ms", "s", "", "m", "h"}. Each caller wraps the unit verbatim in its own UnknownDurationUnit / "unknown duration unit" diagnostic.

Lifted to a pub enum next to duration_from_integer_magnitude_and_unit so the accepted-unit set + the multiplier table + the overflow- arm partition live in exactly one place across every typed-duration codec in caixa-core. A future unit addition (a "us" microsecond suffix once high-resolution timing lands, a "d" day suffix once downstream K8s CR schemas grow multi-day windows) extends this enum + its associated match arm at one site rather than at each codec’s inline dispatch.

Variants§

§

Overflow

The num × multiplier seconds-conversion overflows u64::MAX. multiplier names the exact literal each caller’s pre-lift diagnostic embedded (60 for the minute arm, 3600 for the hour arm), so callers reconstruct the wording losslessly.

Fields

§multiplier: u64

The seconds-multiplier of the unit whose num × multiplier overflowed. 60 for "m", 3600 for "h". The "ms" / "s" / "" arms cannot overflow so no Overflow variant carries a 1000 / 1 / 1 multiplier.

§

UnknownUnit

The trimmed unit suffix is not in the accepted set {"ms", "s", "", "m", "h"}.

Trait Implementations§

Source§

impl Clone for DurationUnitError

Source§

fn clone(&self) -> DurationUnitError

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 DurationUnitError

Source§

impl Debug for DurationUnitError

Source§

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

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

impl Eq for DurationUnitError

Source§

impl PartialEq for DurationUnitError

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DurationUnitError

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<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, 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.