Skip to main content

AnyMessage

Enum AnyMessage 

Source
pub enum AnyMessage {
    Utilmd(UtilmdMessage),
    Mscons(MsconsMessage),
    Aperak(AperakMessage),
    Contrl(ContrlMessage),
    Unknown {
        message_type_code: Box<str>,
        release: Release,
        message_ref: Box<str>,
        segments: Vec<OwnedSegment>,
    },
}
Expand description

A parsed EDI@Energy message, dispatched to its concrete type.

Match on the variants to access type-specific functionality, or use the EdiEnergyMessage trait methods (via msg.validate(), msg.serialize(), etc.) for common operations across all message types.

Each variant is only present when the corresponding Cargo feature is enabled. Compile with --all-features to enable exhaustive matching — this is the recommended pattern for dispatch tables and process-layer routers.

The Unknown variant captures messages whose type is not compiled in or not recognised, preserving the raw segments for routing and forwarding use-cases (e.g. BDEW AS4 adapters).

Variants§

§

Utilmd(UtilmdMessage)

UTILMD — Utilities Master Data message.

§

Mscons(MsconsMessage)

MSCONS — Metered Services Consumption Report.

§

Aperak(AperakMessage)

APERAK — Application Error and Acknowledgement.

§

Contrl(ContrlMessage)

CONTRL — Interchange Control Structure (syntax acknowledgement).

§

Unknown

A message whose type is not recognised or not compiled into this build.

Raw segments are preserved so callers can inspect, log, or forward the message without loss of data. This variant is returned instead of Err(Error::UnknownMessageType) or Err(Error::FeatureNotEnabled) so that gateway / routing applications can handle interchanges with mixed message types without failing the entire parse.

§Example

use edi_energy::{Platform, AnyMessage};

let input: &[u8] = &[];
let msg = Platform::with_all_profiles().parse(input)?;
if let AnyMessage::Unknown { message_type_code, release, .. } = &msg {
    eprintln!("Unhandled message type: {} (release {})", message_type_code, release);
}

Fields

§message_type_code: Box<str>

The EDIFACT type code from UNH DE 0065, e.g. "TRADEX".

§release: Release

The association-assigned release code from UNH DE 0057.

§message_ref: Box<str>

The raw message reference from UNH DE 0062.

§segments: Vec<OwnedSegment>

All parsed segments (UNH … UNT inclusive).

Implementations§

Source§

impl AnyMessage

Source

pub fn is_known(&self) -> bool

Returns true if this message has a recognised, compiled-in type.

Returns false for the Unknown variant.

Source

pub fn try_message_type(&self) -> Option<MessageType>

Returns the message type discriminant, or None for the Unknown variant.

Prefer this over the EdiEnergyMessage::try_message_type trait method when working with an AnyMessage value that may be Unknown.

Source

pub fn as_utilmd(&self) -> Option<&UtilmdMessage>

Returns a reference to the inner UtilmdMessage, or None.

Source

pub fn as_mscons(&self) -> Option<&MsconsMessage>

Returns a reference to the inner MsconsMessage, or None.

Source

pub fn as_aperak(&self) -> Option<&AperakMessage>

Returns a reference to the inner AperakMessage, or None.

Source

pub fn as_contrl(&self) -> Option<&ContrlMessage>

Returns a reference to the inner ContrlMessage, or None.

Trait Implementations§

Source§

impl Debug for AnyMessage

Source§

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

Formats the value using the given formatter. Read more
Source§

impl EdiEnergyMessage for AnyMessage

Source§

fn try_message_type(&self) -> Option<MessageType>

Returns the message-type discriminant, or None for unrecognised message types (i.e. AnyMessage::Unknown). Read more
Source§

fn detect_release(&self) -> Result<&Release, Error>

Extracts the EDI@Energy release identifier from the UNH S009 composite (DE 0057). Read more
Source§

fn message_ref(&self) -> &str

Returns the UNH message reference identifier (DE 0062). Read more
Source§

fn detect_pruefidentifikator(&self) -> Result<Pruefidentifikator, Error>

Extracts the Pruefidentifikator from the BGM document-identifier field (DE 1004). Read more
Source§

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

Validate the message using the profile registered for its detected release. Read more
Source§

fn validate_against(&self, release: &Release) -> Result<EdiEnergyReport, Error>

Validate against an explicit release, overriding the detected one. Read more
Source§

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

Serialize the message back to EDIFACT wire bytes. Read more
Source§

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

Returns the raw parsed segments (UNH … UNT inclusive). Read more
Source§

fn validate_with_pack( &self, extra: CustomRulePack, ) -> Result<EdiEnergyReport, Error>

Validate and merge an additional caller-supplied rule pack on top of all built-in validation layers (L1–L5). Read more
Source§

fn validate_on_date( &self, reference_date: Date, ) -> Result<EdiEnergyReport, Error>

Validate the message as if today’s date were reference_date. Read more
Source§

fn validate_with_context( &self, ctx: &ProcessContext, ) -> Result<EdiEnergyReport, Error>

Validate the message for the normative date encoded in ctx. 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.