#[non_exhaustive]pub enum SectorData {
Battery(BatteryData),
Textile(TextileData),
UnsoldGoods(UnsoldGoodsReport),
Steel(SteelData),
Electronics(ElectronicsData),
Construction(ConstructionData),
Tyre(TyreData),
Toy(ToyData),
Aluminium(AluminiumData),
Furniture(FurnitureData),
Detergent(DetergentData),
Other {
sector: String,
data: Value,
},
}Expand description
Typed, sector-specific DPP data — replaces the opaque compliance_data: Value.
Serialises as an internally-tagged object where "sector" is the
discriminant field, e.g.:
{ "sector": "battery", "gtin": "09506000134352", "nominalVoltageV": 3.2, ... }{ "sector": "textile", "fibreComposition": [...], "countryOfManufacturing": "BD" }An unknown sector tag deserialises to SectorData::Other, which keeps
both the tag and the payload verbatim — see the hand-written Deserialize
below for why the derive cannot do this.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Battery(BatteryData)
Textile(TextileData)
UnsoldGoods(UnsoldGoodsReport)
Steel(SteelData)
Electronics(ElectronicsData)
Construction(ConstructionData)
Tyre(TyreData)
Toy(ToyData)
Aluminium(AluminiumData)
Furniture(FurnitureData)
Detergent(DetergentData)
Other
A product group this build has no typed variant for.
sector is the wire tag verbatim and data is the whole object. A
passport for a sector added to the catalog after this crate was
released survives a round trip unchanged — which is the property that
makes adding a product group a data change rather than a release.
Implementations§
Source§impl SectorData
impl SectorData
Sourcepub fn other(data: Value) -> Option<Self>
pub fn other(data: Value) -> Option<Self>
Build an untyped payload, reading the tag from the object’s own
sector field. Falls back to "other" when the object carries none.
Returns None if the tag names a sector this build does type.
§Why this can fail
Other holding a typed sector’s tag would be a second representation of
that sector which does not compare equal to the first: Other("battery")
is not Sector::Battery under Eq or Hash, would miss every typed
match arm, and would be refused by validate_sector_data even though the
same bytes deserialize into a valid Battery. Deserialization already
routes known tags to their variants; this constructor must not offer a
way around it.
Trait Implementations§
Source§impl Clone for SectorData
impl Clone for SectorData
Source§fn clone(&self) -> SectorData
fn clone(&self) -> SectorData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more