use std::io;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Invalid connect return code: {0}")]
InvalidConnectReturnCode(u8),
#[error("Invalid packet type: {0}")]
InvalidPacketType(u8),
#[error("Invalid protocol level: {0}")]
InvalidProtocolLevel(u8),
#[error("Invalid protocol name: {0}")]
InvalidProtocolName(String),
#[error("Invalid property: {0}")]
InvalidProperty(u8),
#[error("Invalid QoS: {0} (must be 0, 1, or 2)")]
InvalidQos(u8),
#[error("Invalid reason code: {0}")]
InvalidReasonCode(u8),
#[error("Invalid retain handling: {0}")]
InvalidRetainHandling(u8),
#[error("Invalid topic name: {0}")]
InvalidTopicName(String),
#[error("Invalid topic filter: {0}")]
InvalidTopicFilter(String),
#[error("Invalid UTF-8 data in string field")]
InvalidUtf8,
#[error("IO error: {0}")]
Io(#[from] io::Error),
#[error("Malformed variable byte integer encoding")]
MalformedVariableByteInteger,
#[error("Malformed packet structure")]
MalformedPacket,
#[error("The payload of packet must contain at least one return code")]
NoCodes,
#[error("Insufficient bytes to frame packet: expected at least {0} more bytes")]
NotEnoughBytes(usize),
#[error("The payload of packet must contain at least one topic filter")]
NoTopic,
#[error("Outgoing payload size limit exceeded: {0} bytes")]
OutgoingPayloadSizeLimitExceeded(usize),
#[error("Out of bounds access during packet parsing")]
OutOfBounds,
#[error("Payload too large for the current configuration")]
PayloadTooLarge,
#[error("Payload required for this packet type")]
PayloadRequired,
#[error("Payload size limit exceeded: {0} bytes")]
PayloadSizeLimitExceeded(usize),
#[error("Protocol violation detected")]
ProtocolError,
#[error("Protocol version mismatch")]
ProtocolMismatch,
#[error("Protocol not supported by this implementation")]
ProtocolNotSupported,
#[error("Property mismatch between expected and received values")]
PropertyMismatch,
#[error("String exceeds maximum allowed length")]
StringTooLong,
}