Skip to main content

DvgwMessage

Struct DvgwMessage 

Source
#[non_exhaustive]
pub struct DvgwMessage {
Show 14 fields pub message_type: DvgwMessageType, pub document: DvgwDocument, pub carrier: Carrier, pub version: Option<DvgwVersion>, pub message_ref: String, pub document_number: Option<String>, pub pruefidentifikator: Option<Pruefidentifikator>, pub timezone: UtcOffset, pub message_datetime: Option<OffsetDateTime>, pub validity_period: Option<DvgwPeriod>, pub original_nomination_datetime: Option<OffsetDateTime>, pub references: Vec<Reference>, pub parties: Vec<Party>, pub items: Vec<LineItem>, /* private fields */
}
Expand description

A parsed DVGW message.

One type serves ALOCAT, NOMINT, NOMRES and SSQNOT: the four share a structure and differ only in which qualifiers are legal, which is a validation concern. Match on message_type or document when the family matters.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§message_type: DvgwMessageType

The logical family, derived from the document code.

§document: DvgwDocument

BGM C002 DE 1001 — what this message is.

§carrier: Carrier

UNH DE 0065 — the UN/EDIFACT carrier the document rode in on.

§version: Option<DvgwVersion>

UNH S009 DE 0057 — the DVGW package code or message version.

§message_ref: String

UNH DE 0062 message reference.

§document_number: Option<String>

BGM C106 DE 1004 Dokumentennummer.

§pruefidentifikator: Option<Pruefidentifikator>

SG1 RFF+Z13 Prüfidentifikator.

§timezone: UtcOffset

The zone DTM+Z05 declares, as a whole-hour offset. Defaults to UTC, which is what DTM+Z05:0:805 says and what every shipped package uses.

§message_datetime: Option<OffsetDateTime>

DTM+137 — Datum und Zeit der Nachricht.

§validity_period: Option<DvgwPeriod>

DTM+Z01 — Gültigkeitszeitraum der Nachricht.

For ALOCAT, NOMINT and NOMRES this is the gas day the message reports on; for SSQNOT the Abrechnungszeitraum of the Mehr-/Mindermenge.

§original_nomination_datetime: Option<OffsetDateTime>

SG1 DTM+9 — Bearbeitungs-/Verarbeitungsdatum of the original nomination a re-nomination corrects (NOMINT, beside RFF+AGO).

§references: Vec<Reference>

Header RFF segments in wire order.

§parties: Vec<Party>

Header parties in wire order (NAD+MS, NAD+MR, NAD+ZSY).

§items: Vec<LineItem>

The LIN positions.

Implementations§

Source§

impl DvgwMessage

Source

pub fn sender(&self) -> Option<&Party>

The sender from NAD+MS.

Source

pub fn receiver(&self) -> Option<&Party>

The receiver from NAD+MR.

Source

pub fn party(&self, role: &str) -> Option<&Party>

The first header party with the given NAD role.

Source

pub fn reference(&self, qualifier: &str) -> Option<&str>

The first header reference with the given RFF qualifier.

Source

pub fn clearingnummer(&self) -> Option<&str>

RFF+ANX — the ALOCAT Clearingnummer.

Source

pub fn original_nomination_ref(&self) -> Option<&str>

RFF+AGO — the NOMINT reference to the nomination this one corrects.

This is the correlation key for a re-nomination chain. RFF+Z13 is the Prüfidentifikator and correlates nothing.

Source

pub fn quantities(&self) -> impl Iterator<Item = &Quantity>

Every quantity in the message, flattened across positions and locations.

Source

pub fn energy_by_qualifier(&self) -> EnergyByQualifier

Energy totals in kWh, one per QTY qualifier.

Each quantity is integrated over its own period (Quantity::energy_kwh) and summed within its qualifier — the qualifier is the direction (Z02 in, Z03 out), so a figure across them would be a net position.

A quantity that cannot be converted is omitted; energy_is_complete reports whether any were.

Source

pub fn energy_by_qualifier_where( &self, keep: impl Fn(&LineItem) -> bool, ) -> EnergyByQualifier

energy_by_qualifier over the positions keep selects.

For NOMRES, which reports both sides of a match: IMD 17G labels the quantities the recipient nominated, 18G the counterparty’s, 16G the matched result.

Source

pub fn single_energy_kwh( &self, keep: impl Fn(&LineItem) -> bool + Copy, ) -> Option<Decimal>

The single energy total this message states, in kWh, or None.

None when the selected positions carry more than one QTY qualifier — Z02 in and Z03 out make a net position, not a total — and None when nothing could be integrated or some quantity was dropped. energy_by_qualifier_where gives the per-direction figures.

Source

pub fn energy_is_complete(&self) -> bool

true when every quantity in the message contributed to energy_by_qualifier.

false means at least one was dropped, so the totals are a floor rather than a figure — check this before booking one.

Source

pub fn segments(&self) -> &[OwnedSegment]

The raw segments (UNHUNT, plus any envelope that was parsed with them).

Source

pub fn serialize(&self) -> Result<Vec<u8>, Error>

Render the message back to EDIFACT bytes.

Serialization replays the raw segments, so edits to the typed fields are not reflected. Build an outbound message with MessageBuilder instead of mutating a parsed one.

§Errors

Returns Error::Serialize when a segment value cannot be encoded.

Source§

impl DvgwMessage

Source

pub fn correlation_key(&self) -> Option<CorrelationKey>

The Zuordnungstupel this message is assigned by, with its values read.

Returns None when the Prüfidentifikator is absent or has no published assignment — the message then has no defined way to reach a process, and inventing one would attach it to the wrong stream.

Source

pub fn gas_day(&self) -> Option<Date>

The gas day this message reports on, as YYYY-MM-DD.

Read from DTM+Z01, never from DTM+137.

Source

pub fn process_key(&self) -> Option<String>

The key identifying the process this message belongs to.

The correlation_key plus the period the published tuples leave out: a ZO-T* tuple identifies an object — an account, not one day of it — while a process is one gas day of that object, holding that day’s record and its KoV §6.4 deadline. A Mehr-/Mindermengenmeldung reports an Abrechnungszeitraum rather than a gas day, so its key carries the whole DTM+Z01 period.

A tuple that already names its period is returned unchanged (Zuordnung::scopes_its_own_period): a Clearingnummer identifies one Geschäftsvorfall, which may span several days, and the nomination key carries the gas day as its first element.

Returns None when the message has no published Zuordnung, or when a tuple that needs a period has none to read.

Trait Implementations§

Source§

impl Clone for DvgwMessage

Source§

fn clone(&self) -> DvgwMessage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DvgwMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.