Skip to main content

CcsdsNdmError

Enum CcsdsNdmError 

Source
#[non_exhaustive]
pub enum CcsdsNdmError { Io(Error), Format(Box<FormatError>), Validation(Box<ValidationError>), Epoch(EpochError), UnsupportedMessage(String), UnexpectedEof { context: String, }, }
Expand description

The top-level error type for the CCSDS NDM library.

This enum wraps all possible errors that can occur during NDM parsing, validation, serialization, and I/O.

§Example: Handling Parse Errors

use ccsds_ndm::messages::opm::Opm;
use ccsds_ndm::error::CcsdsNdmError;
use ccsds_ndm::kvn::parser::ParseKvn;

match Opm::from_kvn_str("CCSDS_OPM_VERS = 3.0\n...") {
    Ok(opm) => println!("Parsed: {:?}", opm),
    Err(e) => {
        if let Some(enum_err) = e.as_enum_error() {
            eprintln!("Invalid enum value '{}' for field '{}'", enum_err.value, enum_err.field);
        } else if let Some(validation_err) = e.as_validation_error() {
            eprintln!("Validation error: {}", validation_err);
        } else {
            eprintln!("Error: {}", e);
        }
    }
}

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.
§

Io(Error)

Errors occurring during I/O operations.

§

Format(Box<FormatError>)

Errors related to NDM format or syntax.

§

Validation(Box<ValidationError>)

Errors related to NDM data validation.

§

Epoch(EpochError)

Errors related to CCSDS Epochs.

§

UnsupportedMessage(String)

Error for unsupported CCSDS message types.

§

UnexpectedEof

Error when an unexpected end of input is reached.

Fields

§context: String

Implementations§

Source§

impl CcsdsNdmError

Source

pub fn as_kvn_parse_error(&self) -> Option<&KvnParseError>

Returns the inner KVN parse error if this is a FormatError::Kvn.

Source

pub fn as_validation_error(&self) -> Option<&ValidationError>

Returns the inner validation error if this is a ValidationError.

Source

pub fn as_format_error(&self) -> Option<&FormatError>

Returns the inner format error if this is a FormatError.

Source

pub fn as_epoch_error(&self) -> Option<&EpochError>

Returns the inner epoch error if this is an EpochError.

Source

pub fn as_io_error(&self) -> Option<&Error>

Returns the inner I/O error if this is an IoError.

Source

pub fn as_xml_error(&self) -> Option<&Error>

Returns the inner XML error if this is an XmlError.

Source

pub fn is_format_error(&self) -> bool

Returns true if this is any FormatError.

Source

pub fn is_kvn_error(&self) -> bool

Returns true if this is a KVN FormatError.

Source

pub fn is_validation_error(&self) -> bool

Returns true if this is a ValidationError.

Source

pub fn is_io_error(&self) -> bool

Returns true if this is an I/O error.

Source

pub fn is_epoch_error(&self) -> bool

Returns true if this is an epoch error.

Source

pub fn as_enum_error(&self) -> Option<&EnumParseError>

Returns the inner EnumParseError if this is a FormatError::Enum.

Source

pub fn as_parse_int_error(&self) -> Option<&ParseIntError>

Returns the inner ParseIntError if this is a FormatError::ParseInt.

Source

pub fn as_parse_float_error(&self) -> Option<&ParseFloatError>

Returns the inner ParseFloatError if this is a FormatError::ParseFloat.

Source

pub fn with_location(self, input: &str, offset: usize) -> Self

Populates location information for variants with line info.

Trait Implementations§

Source§

impl AddContext<&str, StrContext> for CcsdsNdmError

Source§

fn add_context( self, _input: &&str, _token: &<&str as Stream>::Checkpoint, context: StrContext, ) -> Self

Append to an existing error custom data Read more
Source§

impl Debug for CcsdsNdmError

Source§

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

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

impl Display for CcsdsNdmError

Source§

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

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

impl Error for CcsdsNdmError

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<Box<FormatError>> for CcsdsNdmError

Source§

fn from(source: Box<FormatError>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<ValidationError>> for CcsdsNdmError

Source§

fn from(source: Box<ValidationError>) -> Self

Converts to this type from the input type.
Source§

impl From<DeError> for CcsdsNdmError

Source§

fn from(e: DeError) -> Self

Converts to this type from the input type.
Source§

impl From<EnumParseError> for CcsdsNdmError

Source§

fn from(e: EnumParseError) -> Self

Converts to this type from the input type.
Source§

impl From<EpochError> for CcsdsNdmError

Source§

fn from(source: EpochError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for CcsdsNdmError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for CcsdsNdmError

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<FormatError> for CcsdsNdmError

Source§

fn from(e: FormatError) -> Self

Converts to this type from the input type.
Source§

impl From<ParseFloatError> for CcsdsNdmError

Source§

fn from(e: ParseFloatError) -> Self

Converts to this type from the input type.
Source§

impl From<ParseIntError> for CcsdsNdmError

Source§

fn from(e: ParseIntError) -> Self

Converts to this type from the input type.
Source§

impl From<SeError> for CcsdsNdmError

Source§

fn from(e: SeError) -> Self

Converts to this type from the input type.
Source§

impl From<ValidationError> for CcsdsNdmError

Source§

fn from(e: ValidationError) -> Self

Converts to this type from the input type.
Source§

impl FromExternalError<&str, CcsdsNdmError> for InternalParserError

Source§

fn from_external_error(input: &&str, e: CcsdsNdmError) -> Self

Like ParserError::from_input but also include an external error.
Source§

impl FromExternalError<&str, EpochError> for CcsdsNdmError

Source§

fn from_external_error(_input: &&str, e: EpochError) -> Self

Like ParserError::from_input but also include an external error.
Source§

impl FromExternalError<&str, ParseFloatError> for CcsdsNdmError

Source§

fn from_external_error(_input: &&str, e: ParseFloatError) -> Self

Like ParserError::from_input but also include an external error.
Source§

impl FromExternalError<&str, ParseIntError> for CcsdsNdmError

Source§

fn from_external_error(_input: &&str, e: ParseIntError) -> Self

Like ParserError::from_input but also include an external error.

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> 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.