#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.message_type: DvgwMessageTypeThe logical family, derived from the document code.
document: DvgwDocumentBGM C002 DE 1001 — what this message is.
carrier: CarrierUNH 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: StringUNH DE 0062 message reference.
document_number: Option<String>BGM C106 DE 1004 Dokumentennummer.
pruefidentifikator: Option<Pruefidentifikator>SG1 RFF+Z13 Prüfidentifikator.
timezone: UtcOffsetThe 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
impl DvgwMessage
Sourcepub fn party(&self, role: &str) -> Option<&Party>
pub fn party(&self, role: &str) -> Option<&Party>
The first header party with the given NAD role.
Sourcepub fn reference(&self, qualifier: &str) -> Option<&str>
pub fn reference(&self, qualifier: &str) -> Option<&str>
The first header reference with the given RFF qualifier.
Sourcepub fn clearingnummer(&self) -> Option<&str>
pub fn clearingnummer(&self) -> Option<&str>
RFF+ANX — the ALOCAT Clearingnummer.
Sourcepub fn original_nomination_ref(&self) -> Option<&str>
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.
Sourcepub fn quantities(&self) -> impl Iterator<Item = &Quantity>
pub fn quantities(&self) -> impl Iterator<Item = &Quantity>
Every quantity in the message, flattened across positions and locations.
Sourcepub fn energy_by_qualifier(&self) -> EnergyByQualifier
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.
Sourcepub fn energy_by_qualifier_where(
&self,
keep: impl Fn(&LineItem) -> bool,
) -> EnergyByQualifier
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.
Sourcepub fn single_energy_kwh(
&self,
keep: impl Fn(&LineItem) -> bool + Copy,
) -> Option<Decimal>
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.
Sourcepub fn energy_is_complete(&self) -> bool
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.
Sourcepub fn segments(&self) -> &[OwnedSegment] ⓘ
pub fn segments(&self) -> &[OwnedSegment] ⓘ
The raw segments (UNH … UNT, plus any envelope that was parsed with them).
Sourcepub fn serialize(&self) -> Result<Vec<u8>, Error>
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
impl DvgwMessage
Sourcepub fn correlation_key(&self) -> Option<CorrelationKey>
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.
Sourcepub fn gas_day(&self) -> Option<Date>
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.
Sourcepub fn process_key(&self) -> Option<String>
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
impl Clone for DvgwMessage
Source§fn clone(&self) -> DvgwMessage
fn clone(&self) -> DvgwMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more