Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 22 variants Parse(EdifactError), Serialize(String), FeatureNotEnabled { message_type: String, feature: String, }, UnknownMessageType { raw_code: String, }, MissingSegment(&'static str), MalformedSegment(&'static str), MissingPruefidentifikator, InvalidPruefidentifikatorRange(u32), InvalidPruefidentifikatorFormat { raw_value: String, }, MissingRelease, InvalidRelease(&'static str), ProfileNotFound { message_type: MessageType, release: Release, }, ProfileArchived { message_type: MessageType, release: Release, feature_flag: &'static str, }, ProfileNotYetActive { message_type: MessageType, release: Release, valid_from: Date, date: Date, }, ProfileExpired { message_type: MessageType, release: Release, valid_until: Date, date: Date, }, Validation { count: usize, report: EdiEnergyReport, }, Io(Error), Profile(ProfileError), InterchangeCountMismatch { declared: usize, actual: usize, }, InterchangeRefMismatch { unb_ref: String, unz_ref: String, }, TooManyMessages { limit: usize, }, TooManySegmentsInMessage { limit: usize, actual: usize, },
}
Expand description

All errors that can be produced by edi-energy.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Parse(EdifactError)

The underlying EDIFACT parser rejected the input.

§

Serialize(String)

Writing an EDIFACT structure failed (envelope or segment serialization).

Distinct from Parse: the input was accepted, but the output could not be rendered — e.g. a value outside the UNOC character set or beyond a data element’s length bound.

§

FeatureNotEnabled

The message type is known but the corresponding Cargo feature is not compiled in.

Enable the feature Cargo feature for this crate to parse message_type messages.

Fields

§message_type: String

The EDIFACT message type code, e.g. "UTILMD".

§feature: String

The Cargo feature name that must be enabled, e.g. "utilmd".

§

UnknownMessageType

The message type code from UNH is not recognised by this crate at all.

The raw code is not included in Display output to avoid GDPR-sensitive data leaking into operator logs. Access the code via the raw_code field when needed for diagnostic purposes.

The raw_code value is sanitized at construction: characters outside ASCII alphanumeric and . are replaced with ? so log-injection sequences are neutralized before the value enters any tracing span or log record.

Fields

§raw_code: String

The sanitized UNH type code. Not emitted in Display; available for debugging.

§

MissingSegment(&'static str)

A mandatory EDIFACT segment is absent from the message.

§

MalformedSegment(&'static str)

A segment was found but its content is structurally invalid.

§

MissingPruefidentifikator

The BGM document-identifier field (Pruefidentifikator) was not present.

§

InvalidPruefidentifikatorRange(u32)

A parsed Pruefidentifikator is outside the valid 5-digit range (10000–99999).

The invalid numeric value is carried as context for diagnostic messages.

§

InvalidPruefidentifikatorFormat

The Pruefidentifikator field is not a decimal integer at all.

The raw field value is not included in Display output to avoid GDPR-sensitive data (process codes) leaking into operator logs. Access via raw_value field for diagnostic purposes. This is distinct from Error::InvalidPruefidentifikatorRange so callers can cleanly distinguish “wrong number” from “not a number”.

Fields

§raw_value: String

The raw non-numeric field value. Not emitted in Display; available for debugging.

§

MissingRelease

The release / association-code field in UNH was absent or empty.

§

InvalidRelease(&'static str)

A release code supplied to Release::try_new failed validation.

§

ProfileNotFound

No profile was registered for the given message type + release combination.

Run cargo xtask codegen to generate profile data from profiles/**.

Fields

§message_type: MessageType

The EDIFACT message type.

§release: Release

The release / association code.

§

ProfileArchived

The requested profile is compiled out — enable the feature flag to include it.

This error is returned when the release/message-type combination is a known archived profile that exists in the edi-energy codebase but is excluded from the current build by a feature gate (e.g. contrl-archive, mscons-archive, insrpt-archive, or the catch-all archive feature).

§How to fix

Add the required feature to your Cargo.toml:

[dependencies]
edi-energy = { version = "...", features = ["contrl-archive"] }
§Background

Archived profiles are kept in the source tree for retroactive validation (audit / dispute resolution) but excluded from default builds to keep binary size and compile times small. For the contrl message type, the archived FV2025-10-01 profile covers interchanges from October 2025 – December 2025 (before contrl_fv20260101 became active on 2026-01-01).

Fields

§message_type: MessageType

The EDIFACT message type.

§release: Release

The release / association code.

§feature_flag: &'static str

The Cargo feature flag needed to include this profile.

§

ProfileNotYetActive

The requested profile exists but has not yet become normatively valid on date.

The profile’s valid_from is in the future relative to the processing date. Either use a later processing date, or accept the outgoing profile for now.

Fields

§message_type: MessageType

The EDIFACT message type.

§release: Release

The release / association code.

§valid_from: Date

The date the profile first becomes valid.

§date: Date

The date that was requested.

§

ProfileExpired

The requested profile has expired on date.

The profile’s valid_until date is before the processing date. Use the successor profile that is valid on this date instead.

Fields

§message_type: MessageType

The EDIFACT message type.

§release: Release

The release / association code.

§valid_until: Date

The last date the profile was valid.

§date: Date

The date that was requested.

§

Validation

Validation completed but the report contains at least one error-level issue.

Inspect EdiEnergyReport for the full list of findings.

Fields

§count: usize

Number of error-level issues.

§report: EdiEnergyReport

The full validation report.

§

Io(Error)

A wrapped I/O error (e.g. from reader-based parsing).

§

Profile(ProfileError)

A profile configuration error (bad or missing profile data).

This error is returned when a programmatically constructed profile omits mandatory fields. Profiles generated by cargo xtask codegen never produce this error.

§

InterchangeCountMismatch

The UNZ message count does not match the number of UNH…UNT pairs found in the interchange.

Indicates a truncated, padded, or tampered interchange.

Fields

§declared: usize

Count declared in the UNZ segment.

§actual: usize

Count of UNH…UNT message windows actually found.

§

InterchangeRefMismatch

The interchange control reference in UNZ does not match the one in UNB.

Per EDIFACT syntax, UNZ DE 0036 must equal UNB DE 0020.

Fields

§unb_ref: String

Control reference from the UNB segment.

§unz_ref: String

Control reference from the UNZ segment.

§

TooManyMessages

The interchange exceeds the configured max_messages_per_interchange limit.

Increase crate::ParseConfig::max_messages_per_interchange or process a smaller interchange.

Fields

§limit: usize

The configured limit.

§

TooManySegmentsInMessage

A single EDIFACT message (UNH…UNT) exceeds the configured max_segments_per_message limit.

Increase crate::ParseConfig::max_segments_per_message or reject the oversized message. This limit is a DoS defence for the inbound parser path.

Fields

§limit: usize

The configured per-message limit.

§actual: usize

The number of segments in the offending message.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<EdifactError> for Error

Source§

fn from(source: EdifactError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ProfileError> for Error

Source§

fn from(source: ProfileError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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> ToCompactString for T
where T: Display,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.