pub type Result<T> = std::result::Result<T, SparkplugError>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum SparkplugError {
#[error("invalid Sparkplug topic: {0}")]
InvalidTopic(String),
#[error("invalid Sparkplug identifier: {0}")]
InvalidId(String),
#[error("unexpected end of input while decoding protobuf")]
Truncated,
#[error("protobuf varint overflowed 64 bits")]
VarintOverflow,
#[error("unsupported protobuf wire type {0}")]
InvalidWireType(u8),
#[error("invalid UTF-8 in string field")]
InvalidUtf8,
#[error("unknown Sparkplug data type code {0}")]
UnknownDataType(u32),
#[error("missing datatype for metric (no birth/alias mapping): {0}")]
MissingDataType(String),
#[error("packed array length {len} is not a multiple of element width {width}")]
ArrayLength {
len: usize,
width: usize,
},
#[error("invalid DataSet shape: {0}")]
DataSetShape(String),
#[error("value/datatype mismatch: {0}")]
ValueTypeMismatch(String),
#[error("maximum nesting depth exceeded while decoding")]
RecursionLimit,
#[error("invalid STATE payload: {0}")]
InvalidState(String),
#[error("bdSeq store I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("MQTT transport error: {0}")]
Transport(String),
}