Skip to main content

MessageBuilder

Struct MessageBuilder 

Source
pub struct MessageBuilder { /* private fields */ }
Expand description

Builds a complete DVGW message.

The document code decides the family, the carrier and the UNH header, so there is one builder rather than one per message type.

Implementations§

Source§

impl MessageBuilder

Source

pub fn new(document: DvgwDocument) -> Self

Start a message of the given document type.

Source

pub fn message_ref(self, value: impl Into<String>) -> Self

UNH DE 0062 message reference (mirrored in UNT).

Source

pub fn document_number(self, value: impl Into<String>) -> Self

BGM C106 DE 1004 Dokumentennummer.

Source

pub fn version(self, value: impl Into<String>) -> Self

UNH S009 DE 0057 — the package code (DVGW17) or version (5.11a). Defaults to what the family’s Nachrichtenbeschreibung prescribes (DvgwMessageType::anwendungscode).

Source

pub fn pruefidentifikator(self, pid: u32) -> Self

SG1 RFF+Z13 Prüfidentifikator.

Source

pub fn message_datetime(self, value: OffsetDateTime) -> Self

DTM+137 Datum und Zeit der Nachricht.

Source

pub fn validity_period(self, period: DvgwPeriod) -> Self

DTM+Z01 Gültigkeitszeitraum — the gas day for ALOCAT, NOMINT and NOMRES, the Abrechnungszeitraum for SSQNOT.

Source

pub fn sender(self, code: impl Into<String>) -> Self

NAD+MS Absender, coded under the DVGW agency (332).

Source

pub fn sender_coded( self, code: impl Into<String>, agency: impl Into<String>, ) -> Self

NAD+MS Absender under an explicit DE 3055 agency (9 for a GLN).

Source

pub fn receiver(self, code: impl Into<String>) -> Self

NAD+MR Empfänger, coded under the DVGW agency (332).

Source

pub fn receiver_coded( self, code: impl Into<String>, agency: impl Into<String>, ) -> Self

NAD+MR Empfänger under an explicit DE 3055 agency (9 for a GLN).

Source

pub fn party(self, role: impl Into<String>, code: impl Into<String>) -> Self

Any further header NAD, e.g. ZSY (zusätzlicher BKV), under 332.

Source

pub fn party_coded( self, role: impl Into<String>, code: impl Into<String>, agency: impl Into<String>, ) -> Self

party under an explicit DE 3055 agency.

Source

pub fn clearingnummer(self, value: impl Into<String>) -> Self

RFF+ANX Clearingnummer (ALOCAT), written first in SG1 as the Nachrichtenstruktur orders it.

Source

pub fn original_nomination( self, value: impl Into<String>, processed_at: OffsetDateTime, ) -> Self

RFF+AGO — the nomination this one corrects (NOMINT) — with the DTM+9 Bearbeitungsdatum NOMINT 4.6 marks Erforderlich beside it.

Source

pub fn reference( self, qualifier: impl Into<String>, value: impl Into<String>, ) -> Self

Any further header RFF, written after the ones the structure orders.

Source

pub fn position(self, position: Position) -> Self

Append a position.

Source

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

Render the message as UNHUNT EDIFACT bytes.

The interchange envelope is deliberately not written: the AS4 layer owns UNB/UNZ and its control reference, and a second writer would have to guess at both.

§Errors

Returns Error::Serialize when a mandatory field was never set — the Dokumentennummer, the Prüfidentifikator, the two timestamps, both parties, or at least one position.

Trait Implementations§

Source§

impl Clone for MessageBuilder

Source§

fn clone(&self) -> MessageBuilder

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 MessageBuilder

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.