Skip to main content

CodeEnum

Trait CodeEnum 

Source
pub trait CodeEnum:
    Sized
    + Clone
    + 'static {
    const VALUES: &'static [&'static str];

    // Required methods
    fn as_str(&self) -> &str;
    fn from_code(code: &str) -> Option<Self>;
}
Expand description

A BO4E code value set (generated by [code_enum!] or [key_enum!]).

Required Associated Constants§

Source

const VALUES: &'static [&'static str]

Written values, one per known variant.

Required Methods§

Source

fn as_str(&self) -> &str

The value the mapping engine writes into BO4E JSON.

Source

fn from_code(code: &str) -> Option<Self>

The variant for a written value or any raw EDIFACT code alias. Open enums ([code_enum!]) keep any other code; closed ones return None.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§