Skip to main content

MessageEnvelope

Struct MessageEnvelope 

Source
pub struct MessageEnvelope {
    pub message: AnyMessage,
    pub header: InterchangeHeader,
    pub message_index: usize,
}
Expand description

A single parsed message together with its enclosing interchange envelope header.

When an interchange contains multiple messages, each yields a separate MessageEnvelope from ParsedInterchange::messages.

Fields§

§message: AnyMessage

The parsed message.

§header: InterchangeHeader

The interchange header from the enclosing UNB segment.

§message_index: usize

0-based index of this message within the interchange.

Implementations§

Source§

impl MessageEnvelope

Source

pub fn validate(&self) -> Result<EdiEnergyReport, Error>

Validate the message using the profile registry.

Delegates to EdiEnergyMessage::validate for all known message types. For AnyMessage::Unknown this returns Ok(report) where the report contains a single Warning with rule ID "UNKNOWN-MSG-TYPE", consistent with the behaviour of EdiEnergyMessage::validate_against on unknown variants.

Rationale for returning Ok instead of Err: an interchange may legitimately contain message types that are not compiled into the current binary (e.g. when only the mscons feature is enabled). Returning Err would abort validation of the entire interchange on the first unknown message, preventing valid messages later in the interchange from being validated. Callers that want strict unknown-type rejection can check report.is_valid() && report.warnings().is_empty() after the fact.

§Errors

Returns crate::Error::ProfileNotFound when no profile matches the message’s release code (known message type, unregistered release).

Source

pub fn is_wire_code_acceptable_on( &self, date: Date, registry: &ReleaseRegistry, ) -> bool

Return true when the wire release code in this message is normatively acceptable on date (considering the grace window configured on registry).

Pass the registry from the owning crate::Platform rather than calling this via the global singleton. Using an explicit registry is required for test isolation and multi-tenant deployments.

For convenience in simple single-registry programs, call MessageEnvelope::is_wire_code_acceptable_on_global instead.

Source

pub fn is_wire_code_acceptable_on_global(&self, date: Date) -> bool

Convenience wrapper that uses the process-global registry.

Prefer MessageEnvelope::is_wire_code_acceptable_on with an explicit registry when working with a crate::Platform instance.

Source

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

Extract the sender’s party identifier from a 13-digit numeric sender ID (BDEW code, agency 293, or GS1 GLN, agency 9), or return None.

Returns None for 16-char EIC codes — check InterchangeHeader::sender_id directly when EIC senders are expected.

Source

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

Extract the receiver’s party identifier from a 13-digit numeric receiver ID, or return None.

Source

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

The transmission date from the interchange header, if present.

Source

pub fn receipt_context(&self) -> ReceiptContext<'_>

Build a ReceiptContext for constructing an acknowledgement.

The context mirrors sender/receiver so that AperakBuilder::for_receipt() and ContrlBuilder::for_interchange() swap them correctly.

Trait Implementations§

Source§

impl Debug for MessageEnvelope

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.