pub mod errors {
use crate::sacn_parse_pack_error::ParsePacketError;
use thiserror::Error;
use uuid::Uuid;
pub type Result<T> = std::result::Result<T, SacnError>;
#[derive(Debug, Error)]
pub enum SacnError {
#[error("Io error occurred: {0}")]
Io(#[from] std::io::Error),
#[error("String error occurred: {0}")]
Str(#[from] std::str::Utf8Error),
#[error("Uuid error occurred: {0}")]
Uuid(#[from] uuid::Error),
#[error("The given buffer fits {0} bytes, but {1} bytes were read.")]
TooManyBytesRead(usize, usize),
#[error("SacnParsePack error occurred: {0}")]
SacnParsePackError(#[from] ParsePacketError),
#[error("The given source name was malformed and couldn't be used, msg: {0}")]
MalformedSourceName(String),
#[error(
"Priority must be within allowed range of [0-E131_MAX_PRIORITY], priority provided: {0}"
)]
InvalidPriority(u8),
#[error("Limit for the number of supported sources has been reached: {0}")]
SourcesExceededError(usize),
#[error("Source discovered with announce_discovery_flag set to true: {0}")]
SourceDiscovered(String),
#[error("Attempted to exceed the capacity of a single universe, data len: {0}")]
ExceedUniverseCapacity(usize),
#[error("Attempted to use an illegal universe: {0}")]
IllegalUniverse(u16),
#[error("Attempted to use an illegal synchronization universe: {0}")]
IllegalSyncUniverse(u16),
#[error("Attempted to use a universe that wasn't registered: {0}")]
UniverseNotRegistered(u16),
#[error("Multicast address and interface_addr not same IP version.")]
IpVersionError(),
#[error("Unsupported IP version used: {0}")]
UnsupportedIpVersion(String),
#[error("Attempted to use a sender which has already been terminated: {0}")]
SenderAlreadyTerminated(String),
#[error(
"Error when merging DMX data. Attempted DMX merge on dmx data with different universes, synchronisation universes or data with no values"
)]
DmxMergeError(),
#[error(
"Packet received with sequence number {0} is out of sequence, last {1}, seq-diff {2}"
)]
OutOfSequence(u8, u8, isize),
#[error("Source terminated universe, source cid: {0}, universe: {1}")]
UniverseTerminated(Uuid, u16),
#[error("Source universe timed out, source cid: {0}, universe: {1}")]
UniverseTimeout(Uuid, u16),
#[error("When looking for a specific universe it wasn't found, universe: {0}")]
UniverseNotFound(u16),
#[error("Source not found: {0}")]
SourceNotFound(Uuid),
#[error("Operation attempted is unsupported on the current OS: {0}")]
OsOperationUnsupported(String),
#[error(
"The sACN source has corrupted due to an internal panic! and should no longer be used, {0}"
)]
SourceCorrupt(String),
#[error("Data array has length 0, must provide data to send")]
DataArrayEmpty(),
#[error("Universe list has length 0, must provide at least one universe")]
UniverseListEmpty(),
#[error(
"Source_limit has a value of Some(0) which would indicate this receiver can never receive from any source"
)]
SourceLimitZero(),
#[error(
"Attempting to receive data with no data universes registered, an infinite timeout and no discovery announcements"
)]
NoDataUniversesRegistered(),
}
}