#[non_exhaustive]pub enum EdifactError {
Show 20 variants
UnexpectedEof {
offset: usize,
},
InvalidDelimiter {
byte: u8,
offset: usize,
},
InvalidText {
offset: usize,
},
InvalidReleaseSequence {
offset: usize,
},
MessageCountMismatch {
expected: u32,
actual: u32,
},
SegmentCountMismatch {
expected: u32,
actual: u32,
message_ref: String,
},
InvalidSegmentTag(String),
InvalidUna,
MissingRequiredElement {
tag: String,
element_index: usize,
},
InvalidUtf8,
Io(IoError),
InvalidSegmentForMessage {
tag: String,
message_type: String,
offset: usize,
},
InvalidElementCount {
tag: String,
min: usize,
max: usize,
actual: usize,
offset: usize,
},
InvalidComponentCount {
tag: String,
element_index: usize,
expected: u8,
actual: u8,
offset: usize,
},
InvalidCodeValue {
tag: String,
element_index: usize,
value: String,
code_list: String,
offset: usize,
suggestion: Option<&'static str>,
},
MissingSegment {
tag: String,
expected_position: String,
},
QualifierMismatch {
tag: String,
actual: String,
expected: String,
offset: usize,
},
ConditionalRequirementNotMet {
tag: String,
element_index: usize,
condition: String,
offset: usize,
},
ValidationFailed {
error_count: usize,
first_message: String,
},
SegmentTooLong {
offset: usize,
limit: usize,
},
}Expand description
All errors produced by edifact-rs.
§Error Variants
All variants that include an offset carry byte position information from the input stream. This data enables precise error location reporting in diagnostics.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnexpectedEof
Unexpected end of input while parsing.
This typically occurs when a segment terminator or expected delimiter is not found before the end of the input stream.
InvalidDelimiter
Invalid byte encountered in a delimiter context.
Delimiters must be precisely ASCII characters from the UNA service string advice. Any other byte is invalid in delimiter position.
Fields
InvalidText
Invalid UTF-8 sequence in parsed text.
While EDIFACT operates on bytes, segments and elements are expected to contain valid UTF-8 text. Non-UTF-8 sequences are rejected at parse time.
InvalidReleaseSequence
Invalid release-character escape sequence in parsed text.
The release character (? by default) must be followed by one escaped byte.
A trailing release character without a following byte is malformed.
MessageCountMismatch
UNZ interchange message count does not match the number of UNH/UNT pairs found.
The UNZ segment declares the number of messages in the interchange,
but the actual number of UNH/UNT pairs observed differs.
Fields
SegmentCountMismatch
UNT segment count does not match the actual number of segments in the message.
The UNT segment declares the number of segments in the message (including UNH/UNT),
but the actual count differs.
Fields
InvalidSegmentTag(String)
Invalid or malformed segment tag.
Segment tags must be exactly 3 ASCII uppercase letters.
InvalidUna
Invalid UNA service string advice.
If present, the UNA segment must be exactly 9 bytes: “UNA” followed by 6 service characters.
MissingRequiredElement
Missing required element in a segment.
Certain segments require specific elements to be present. This error indicates a mandatory element was not found.
Fields
InvalidUtf8
Output serialization produced invalid UTF-8.
This is an internal consistency error; the writer should never produce non-UTF-8 output. If this occurs, it indicates a bug in the serialization logic.
Io(IoError)
I/O error from reading or writing.
InvalidSegmentForMessage
Segment is not valid for the current message type.
Structural validation found a segment that should not appear in this message.
Fields
InvalidElementCount
Element count in segment exceeds or falls short of directory definition.
Validation against directory metadata found an element count mismatch.
Fields
InvalidComponentCount
Component count in a composite element is invalid.
A composite data element does not have the expected number of components.
Fields
InvalidCodeValue
Code-list value is not valid.
The value appears in a field that should contain a code from a specific code list, but the value is not in that code list.
Fields
MissingSegment
A required segment is missing from the message.
Structural validation found that a mandatory segment is absent.
QualifierMismatch
Qualifier does not match expected value for segment.
A qualified segment (e.g., NAD+MS) has a qualifier that does not match expected.
Fields
ConditionalRequirementNotMet
Conditional requirement not met.
A segment or element is conditionally required based on another element’s value, but the condition was not satisfied.
Fields
ValidationFailed
Aggregate validation failure from strict validation mode.
Fields
SegmentTooLong
Segment exceeded the configured maximum byte length.
Returned by reader-based parsers when an unterminated segment accumulates more
bytes than the configured max_segment_bytes limit in ReaderConfig. This
prevents resource exhaustion on adversarially crafted or truncated input that
never emits a segment terminator.
Implementations§
Source§impl EdifactError
impl EdifactError
Sourcepub const fn stable_code(&self) -> &'static str
pub const fn stable_code(&self) -> &'static str
Stable diagnostic code for this error variant.
Sourcepub fn recovery_hint(&self) -> Option<&'static str>
pub fn recovery_hint(&self) -> Option<&'static str>
Stable recovery hint for common malformed input and validation cases.
Trait Implementations§
Source§impl Debug for EdifactError
impl Debug for EdifactError
Source§impl Diagnostic for EdifactError
Available on crate feature diagnostics only.
impl Diagnostic for EdifactError
diagnostics only.Source§fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz) is recommended, but more classic codes like
E0123 or enums will work just fine.Source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read moreSource§fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic. Do you have any
advice for the poor soul who’s just run into this issue?Source§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic.Source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s Diagnostic::labels to.Source§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic’s Diagnostic::source_codeDiagnostics.Source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
Source§impl Display for EdifactError
impl Display for EdifactError
Source§impl Error for EdifactError
impl Error for EdifactError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for EdifactError
impl From<Error> for EdifactError
Source§impl From<IoError> for EdifactError
impl From<IoError> for EdifactError
Source§impl PartialEq for EdifactError
impl PartialEq for EdifactError
Source§fn eq(&self, other: &EdifactError) -> bool
fn eq(&self, other: &EdifactError) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for EdifactError
Auto Trait Implementations§
impl Freeze for EdifactError
impl !RefUnwindSafe for EdifactError
impl Send for EdifactError
impl Sync for EdifactError
impl Unpin for EdifactError
impl UnsafeUnpin for EdifactError
impl !UnwindSafe for EdifactError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more