Skip to main content

EnumVo

Trait EnumVo 

Source
pub trait EnumVo:
    ValueObject
    + FromStr
    + Display
    + Copy
    + 'static
where Self::Err: Error + Send + Sync + 'static,
{ // Required method fn variants() -> &'static [Self]; }
Expand description

A fieldless enum treated as a closed set of named values, round-trippable through its Display/FromStr string form.

variants() and FromStr::from_str are independent trait items with no compiler-enforced relationship between them: nothing requires that every variant from_str accepts also appears in variants(), or vice versa. #[derive(EnumVo)] in ddd-toolkit-macro keeps them consistent by construction, generating both from the same variant list. A hand-written impl (as in this crate’s own test fixtures) must keep them in sync by hand - adding, renaming, or removing a variant in one without mirroring the change in the other breaks the round-trip silently.

Required Methods§

Source

fn variants() -> &'static [Self]

Every variant, in the order chosen by the implementation.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§