use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("unexpected end of input")]
UnexpectedEof,
#[error("invalid tag control bits 0x{0:02x}")]
InvalidTagControl(u8),
#[error("invalid element type 0x{0:02x}")]
InvalidElementType(u8),
#[error("invalid UTF-8 in TLV string: {0}")]
InvalidUtf8(#[from] core::str::Utf8Error),
#[error("integer value out of range for declared width")]
IntegerOutOfRange,
#[error("output buffer too small")]
BufferTooSmall,
#[error("length field overflows usize")]
LengthOverflow,
#[error("unexpected end-of-container marker at top level")]
UnexpectedEndOfContainer,
#[error("container body truncated before end-of-container marker")]
UnclosedContainer,
#[error("container nesting exceeds depth limit")]
ContainerTooDeep,
#[error("array element carried a non-anonymous tag")]
NonAnonymousArrayTag,
#[error("decoded element count exceeds the per-decode budget")]
ElementBudgetExceeded,
#[error("internal fixed-width conversion failure")]
InternalSliceConversion,
}
pub type Result<T> = core::result::Result<T, Error>;