Skip to main content

MapKey

Trait MapKey 

Source
pub trait MapKey: CodeEnum + Ord {
    const FIELD: &'static str;
    const ALSO_FIELD: Option<&'static str>;
    const CODES: &'static [(&'static str, &'static str, Option<&'static str>)];

    // Provided methods
    fn of_element(element: &Value) -> Result<Self, String> { ... }
    fn fill_element(&self, element: &mut Value) { ... }
}
Expand description

Qualifier key of a map-keyed entity collection.

Each variant is a raw EDIFACT qualifier code. CodeEnum::as_str is the code itself (the map key); the element carries it in Self::FIELD (and Self::ALSO_FIELD) as the engine writes it.

Required Associated Constants§

Source

const FIELD: &'static str

Field of an element that carries the qualifier (e.g. "partnerrolle").

Source

const ALSO_FIELD: Option<&'static str>

Second field of a dual decomposition (e.g. "datenqualitaet").

Source

const CODES: &'static [(&'static str, &'static str, Option<&'static str>)]

(raw code, value written to FIELD, value written to ALSO_FIELD), sorted by raw code — the order the engine’s enum_map lookups iterate in.

Provided Methods§

Source

fn of_element(element: &Value) -> Result<Self, String>

Resolve the key of an engine JSON element the way the reverse mapping resolves the qualifier: joint match of both fields, else the first code written as the field’s value, else the field’s value as a raw code.

Source

fn fill_element(&self, element: &mut Value)

Write the key’s qualifier fields into element where they are absent.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§