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);
}Implementations§
Source§impl AnyMessage
impl AnyMessage
Sourcepub fn is_known(&self) -> bool
pub fn is_known(&self) -> bool
Returns true if this message has a recognised, compiled-in type.
Returns false for the Unknown variant.
Sourcepub fn try_message_type(&self) -> Option<MessageType>
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.
Sourcepub fn as_utilmd(&self) -> Option<&UtilmdMessage>
pub fn as_utilmd(&self) -> Option<&UtilmdMessage>
Returns a reference to the inner UtilmdMessage, or None.
Sourcepub fn as_mscons(&self) -> Option<&MsconsMessage>
pub fn as_mscons(&self) -> Option<&MsconsMessage>
Returns a reference to the inner MsconsMessage, or None.
Sourcepub fn as_aperak(&self) -> Option<&AperakMessage>
pub fn as_aperak(&self) -> Option<&AperakMessage>
Returns a reference to the inner AperakMessage, or None.
Sourcepub fn as_contrl(&self) -> Option<&ContrlMessage>
pub fn as_contrl(&self) -> Option<&ContrlMessage>
Returns a reference to the inner ContrlMessage, or None.
Trait Implementations§
Source§impl Debug for AnyMessage
impl Debug for AnyMessage
Source§impl EdiEnergyMessage for AnyMessage
impl EdiEnergyMessage for AnyMessage
Source§fn try_message_type(&self) -> Option<MessageType>
fn try_message_type(&self) -> Option<MessageType>
None for unrecognised
message types (i.e. AnyMessage::Unknown). Read moreSource§fn detect_release(&self) -> Result<&Release, Error>
fn detect_release(&self) -> Result<&Release, Error>
Source§fn message_ref(&self) -> &str
fn message_ref(&self) -> &str
Source§fn detect_pruefidentifikator(&self) -> Result<Pruefidentifikator, Error>
fn detect_pruefidentifikator(&self) -> Result<Pruefidentifikator, Error>
Source§fn validate(&self) -> Result<EdiEnergyReport, Error>
fn validate(&self) -> Result<EdiEnergyReport, Error>
Source§fn validate_against(&self, release: &Release) -> Result<EdiEnergyReport, Error>
fn validate_against(&self, release: &Release) -> Result<EdiEnergyReport, Error>
Source§fn serialize(&self) -> Result<Vec<u8>, Error>
fn serialize(&self) -> Result<Vec<u8>, Error>
Source§fn segments(&self) -> &[OwnedSegment]
fn segments(&self) -> &[OwnedSegment]
Source§fn validate_with_pack(
&self,
extra: CustomRulePack,
) -> Result<EdiEnergyReport, Error>
fn validate_with_pack( &self, extra: CustomRulePack, ) -> Result<EdiEnergyReport, Error>
Source§fn validate_on_date(
&self,
reference_date: Date,
) -> Result<EdiEnergyReport, Error>
fn validate_on_date( &self, reference_date: Date, ) -> Result<EdiEnergyReport, Error>
reference_date. Read moreSource§fn validate_with_context(
&self,
ctx: &ProcessContext,
) -> Result<EdiEnergyReport, Error>
fn validate_with_context( &self, ctx: &ProcessContext, ) -> Result<EdiEnergyReport, Error>
ctx. Read more