Skip to main content

Bo4eObject

Trait Bo4eObject 

Source
pub trait Bo4eObject: Sealed {
    type BoTyp;

    // Required methods
    fn bo_type(&self) -> Self::BoTyp;
    fn schema_version(&self) -> &'static str;
    fn schema_series(&self) -> &'static str;
}
Available on crate feature versioned only.
Expand description

Marker trait implemented by every generated BO4E business object (Geschäftsobjekt).

Provides runtime access to the BO type discriminant and the schema version that was used to generate this type. COM types and enums do NOT implement this trait.

§Sealed trait

Bo4eObject is sealed — it cannot be implemented by types outside this crate. This allows the library to add new methods in future releases without breaking downstream code that merely uses the trait.

§Design note — associated type over bare return type

bo_type() returns Self::BoTyp (an associated type) so that the single trait definition in src/lib.rs can serve all schema versions while keeping each version’s BoTyp enum strongly typed. For dyn usage, bind the associated type:

use rubo4e::current::{BoTyp, Marktlokation, Vertrag};
use rubo4e::Bo4eObject;

let objects: Vec<Box<dyn Bo4eObject<BoTyp = BoTyp>>> = vec![
    Box::new(Vertrag::default()),
    Box::new(Marktlokation::default()),
];
let types: Vec<BoTyp> = objects.iter().map(|o| o.bo_type()).collect();
assert_eq!(types, [BoTyp::Vertrag, BoTyp::Marktlokation]);

§Example

use rubo4e::current::{BoTyp, Vertrag};
use rubo4e::Bo4eObject as _;

let v = Vertrag::default();
assert_eq!(v.bo_type(), BoTyp::Vertrag);
assert_eq!(v.schema_version(), "202607.1.0");  // exact release
assert_eq!(v.schema_series(), "202607");       // the series this module covers

Required Associated Types§

Source

type BoTyp

The BO type discriminant enum for this schema version (e.g. v202607::BoTyp).

Required Methods§

Source

fn bo_type(&self) -> Self::BoTyp

Returns the Self::BoTyp discriminant identifying this business object.

Source

fn schema_version(&self) -> &'static str

Returns the exact BO4E schema release this type was generated from, in the spelling the _version wire field carries (e.g. "202607.1.0").

Note the missing v: BO4E prefixes its git tags with one (v202607.1.0) but the value inside a payload never has it. This accessor reports the wire spelling so it can be compared against a _version read off a message without a normalisation step.

Do not dispatch on this value. BO4E ships patch releases inside a series, so a producer one patch ahead sends "202607.2.0" and an equality match on "202607.1.0" rejects a payload this module handles perfectly. Match on schema_series instead.

Source

fn schema_series(&self) -> &'static str

Returns the schema series — the YYYYMM prefix of the release (e.g. "202607"), without the v the git tag prefixes it with.

This is the granularity at which the crate exposes a module (crate::v202607), and the right key for version dispatch: every release within a series deserializes into the same types.

use rubo4e::{current::Rechnung, Bo4eObject as _};

// A payload's own `_version`, whatever patch the sender is on:
let incoming = "202607.4.0";
assert_eq!(
    incoming.split('.').next(),
    Some(Rechnung::default().schema_series()),
);

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Bo4eObject for Angebot

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Ausschreibung

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Bilanzierung

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Buendelvertrag

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Energiemenge

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Fremdkosten

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Geraet

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Geschaeftspartner

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Kosten

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Lastgang

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Lokationszuordnung

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Marktlokation

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Marktteilnehmer

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Messlokation

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Netzlokation

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Person

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Preisblatt

Available on crate features json or versioned only.
Source§

impl Bo4eObject for PreisblattDienstleistung

Available on crate features json or versioned only.
Source§

impl Bo4eObject for PreisblattHardware

Available on crate features json or versioned only.
Source§

impl Bo4eObject for PreisblattKonzessionsabgabe

Available on crate features json or versioned only.
Source§

impl Bo4eObject for PreisblattMessung

Available on crate features json or versioned only.
Source§

impl Bo4eObject for PreisblattNetznutzung

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Rechnung

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Region

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Standorteigenschaften

Available on crate features json or versioned only.
Source§

impl Bo4eObject for SteuerbareRessource

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Tarif

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Tarifinfo

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Tarifkosten

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Tarifpreisblatt

Available on crate features json or versioned only.
Source§

impl Bo4eObject for TechnischeRessource

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Vertrag

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Zaehler

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Zaehlzeitdefinition

Available on crate features json or versioned only.
Source§

impl Bo4eObject for Zeitreihe

Available on crate features json or versioned only.