use thiserror::Error;
use uuid::Uuid;
#[derive(Debug, Error)]
pub enum ParsePacketError {
#[error("Error when parsing data into packet, msg: {0}")]
ParseInvalidData(String),
#[error(
"Attempted to parse a priority value that is outwith the allowed range of [0, 200]: {0}"
)]
ParseInvalidPriority(u8),
#[error("Error when parsing page value, msg: {0}")]
ParseInvalidPage(String),
#[error(
"Attempted to parse a sync_addr value that is outwith the allowed range of [0, 63999]: {0}"
)]
ParseInvalidSyncAddr(u16),
#[error(
"Attempted to parse a universe value that is outwith the allowed range of [1, 63999]: {0}"
)]
ParseInvalidUniverse(u16),
#[error("Attempted to parse a packet with an invalid ordering of universes, msg: {0}")]
ParseInvalidUniverseOrder(String),
#[error("When packing a packet into a buffer invalid data encountered, msg: {0}")]
PackInvalidData(String),
#[error("Supplied buffer is not large enough to pack packet into, msg: {0}")]
PackBufferInsufficient(String),
#[error("Supplied buffer does not contain enough data, msg: {0}")]
ParseInsufficientData(String),
#[error("PDU Flags {0:#b} are invalid for parsing")]
ParsePduInvalidFlags(u8),
#[error("PDU Length {0} is invalid")]
PduInvalidLength(usize),
#[error("Vector {0:#x} not supported")]
PduInvalidVector(u32),
#[error("Error parsing the received UUID: {0}")]
UuidError(Uuid),
#[error("Error parsing received UTF8 string, msg: {0}")]
Utf8Error(String),
#[error("Source name in packet was not null terminated.")]
SourceNameNotNullTerminated(),
}