use core::fmt;
pub type ExiResult<T> = Result<T, ExiError>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum ExiError {
OutputFull,
UnexpectedEnd,
NonZeroPadding,
IntegerOverflow,
ValueTooLong,
ValueTooShort,
InvalidCodePoint,
InvalidFloat,
InvalidDateTime,
BadHeader,
UnknownEventCode,
BadStringTableIndex,
UnknownEnumValue,
ValueOutOfRange,
TrailingData,
MissingElement,
UnsupportedOption,
DepthLimitExceeded,
}
impl fmt::Display for ExiError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let msg = match self {
Self::OutputFull => "output buffer full",
Self::UnexpectedEnd => "unexpected end of EXI stream",
Self::NonZeroPadding => "non-zero padding bits at end of EXI stream",
Self::IntegerOverflow => "integer out of range",
Self::ValueTooLong => "value exceeds the length permitted by its schema type",
Self::ValueTooShort => "value is shorter than its schema type permits",
Self::InvalidCodePoint => "invalid Unicode code point",
Self::InvalidFloat => "invalid EXI float",
Self::InvalidDateTime => "invalid EXI date-time",
Self::BadHeader => "malformed or unsupported EXI header",
Self::UnknownEventCode => "event code has no production in the grammar",
Self::BadStringTableIndex => "string table index out of range",
Self::UnknownEnumValue => "unknown enumeration value",
Self::ValueOutOfRange => "value outside the range its schema type permits",
Self::TrailingData => "trailing data after end of EXI document",
Self::MissingElement => "required element missing",
Self::UnsupportedOption => "unsupported EXI option",
Self::DepthLimitExceeded => "maximum element nesting depth exceeded",
};
f.write_str(msg)
}
}
#[cfg(feature = "std")]
impl std::error::Error for ExiError {}