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: AnyMessageThe parsed message.
header: InterchangeHeaderThe interchange header from the enclosing UNB segment.
message_index: usize0-based index of this message within the interchange.
Implementations§
Source§impl MessageEnvelope
impl MessageEnvelope
Sourcepub fn validate(&self) -> Result<EdiEnergyReport, Error>
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).
Sourcepub fn is_wire_code_acceptable_on(
&self,
date: Date,
registry: &ReleaseRegistry,
) -> bool
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.
Sourcepub fn is_wire_code_acceptable_on_global(&self, date: Date) -> bool
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.
Sourcepub fn sender_party_id(&self) -> Option<&str>
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.
Sourcepub fn receiver_party_id(&self) -> Option<&str>
pub fn receiver_party_id(&self) -> Option<&str>
Extract the receiver’s party identifier from a 13-digit numeric receiver ID,
or return None.
Sourcepub fn transmission_date(&self) -> Option<Date>
pub fn transmission_date(&self) -> Option<Date>
The transmission date from the interchange header, if present.
Sourcepub fn receipt_context(&self) -> ReceiptContext<'_>
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.