LnmpError

Enum LnmpError 

Source
pub enum LnmpError {
Show 16 variants InvalidCharacter { char: char, line: usize, column: usize, }, UnterminatedString { line: usize, column: usize, }, UnexpectedToken { expected: String, found: Token, line: usize, column: usize, }, InvalidFieldId { value: String, line: usize, column: usize, }, InvalidValue { field_id: u16, reason: String, line: usize, column: usize, }, InvalidChecksum { field_id: u16, reason: String, line: usize, column: usize, }, UnexpectedEof { line: usize, column: usize, }, InvalidEscapeSequence { sequence: String, line: usize, column: usize, }, StrictModeViolation { reason: String, line: usize, column: usize, }, TypeHintMismatch { field_id: u16, expected_type: String, actual_value: String, line: usize, column: usize, }, InvalidTypeHint { hint: String, line: usize, column: usize, }, ChecksumMismatch { field_id: u16, expected: String, found: String, line: usize, column: usize, }, NestingTooDeep { max_depth: usize, actual_depth: usize, line: usize, column: usize, }, InvalidNestedStructure { reason: String, line: usize, column: usize, }, DuplicateFieldId { field_id: u16, line: usize, column: usize, }, UnclosedNestedStructure { structure_type: String, opened_at_line: usize, opened_at_column: usize, line: usize, column: usize, },
}
Expand description

Error type for LNMP parsing and encoding operations

Variants§

§

InvalidCharacter

Invalid character encountered during lexical analysis

Fields

§char: char

The invalid character

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

UnterminatedString

Unterminated string literal

Fields

§line: usize

Line number where the string started

§column: usize

Column number where the string started

§

UnexpectedToken

Unexpected token encountered during parsing

Fields

§expected: String

What token was expected

§found: Token

What token was actually found

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

InvalidFieldId

Invalid field ID (not a valid u16 or out of range)

Fields

§value: String

The invalid value that was encountered

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

InvalidValue

Invalid value for a field

Fields

§field_id: u16

The field ID where the error occurred

§reason: String

Reason why the value is invalid

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

InvalidChecksum

Invalid checksum (wrong format or characters)

Fields

§field_id: u16

The field ID where the error occurred

§reason: String

Reason for invalid checksum

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

UnexpectedEof

Unexpected end of file

Fields

§line: usize

Line number where EOF was encountered

§column: usize

Column number where EOF was encountered

§

InvalidEscapeSequence

Invalid escape sequence in a string

Fields

§sequence: String

The invalid escape sequence

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

StrictModeViolation

Strict mode violation

Fields

§reason: String

Description of the violation

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

TypeHintMismatch

Type hint mismatch

Fields

§field_id: u16

The field ID where the error occurred

§expected_type: String

Expected type from hint

§actual_value: String

Actual value that was parsed

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

InvalidTypeHint

Invalid type hint

Fields

§hint: String

The invalid type hint

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

ChecksumMismatch

Checksum mismatch (v0.3)

Fields

§field_id: u16

The field ID where the error occurred

§expected: String

Expected checksum

§found: String

Found checksum

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

NestingTooDeep

Nesting depth exceeds maximum allowed (v0.3)

Fields

§max_depth: usize

Maximum allowed nesting depth

§actual_depth: usize

Actual depth that was reached

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

InvalidNestedStructure

Invalid nested structure (v0.3)

Fields

§reason: String

Description of the structural issue

§line: usize

Line number where the error occurred

§column: usize

Column number where the error occurred

§

DuplicateFieldId

Duplicate field ID in strict mode

Fields

§field_id: u16

The duplicated field ID

§line: usize

Line number where duplicate was detected

§column: usize

Column number where duplicate was detected

§

UnclosedNestedStructure

Unclosed nested structure (v0.3)

Fields

§structure_type: String

Type of structure (“record” or “array”)

§opened_at_line: usize

Line where structure was opened

§opened_at_column: usize

Column where structure was opened

§line: usize

Line where error was detected

§column: usize

Column where error was detected

Implementations§

Source§

impl LnmpError

Source

pub fn with_context(self, _context: ErrorContext) -> Self

Adds error context with source snippet

Source

pub fn format_with_source(&self, source: &str) -> String

Formats the error with source context for rich error messages

Source

pub fn position(&self) -> (usize, usize)

Returns the line and column position of the error

Trait Implementations§

Source§

impl Clone for LnmpError

Source§

fn clone(&self) -> LnmpError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LnmpError

Source§

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

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

impl Display for LnmpError

Source§

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

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

impl Error for LnmpError

1.30.0 · 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<LnmpError> for BinaryError

Source§

fn from(err: LnmpError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for LnmpError

Source§

fn eq(&self, other: &LnmpError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for LnmpError

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.