use thiserror::Error;
use crate::kairos::DecodeError as KairosDecodeError;
use crate::metis::HaveSetDecodeError;
#[non_exhaustive]
#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum RhapsodyDecodeError {
#[error("unknown rhapsody wire version: {0:#04x}")]
UnknownVersion(u8),
#[error("unexpected rhapsody frame length: expected at least {expected}, found {found}")]
UnexpectedLength {
expected: usize,
found: usize,
},
#[error("rhapsody frame declares {count} loci, past the plane's {capacity} ceiling")]
TooManyLoci {
count: u64,
capacity: u64,
},
#[error("non-canonical rhapsody: zero index for station {station}")]
ZeroDot {
station: u32,
},
#[error("non-canonical rhapsody: dot {found:?} is not strictly after {previous:?}")]
NonAscendingLoci {
previous: (u32, u64),
found: (u32, u64),
},
#[error("non-canonical rhapsody: unknown anchor tag {tag:#04x}")]
BadAnchorTag {
tag: u8,
},
#[error("structurally invalid rhapsody: visible dot ({station}, {index}) has no locus")]
VisibleWithoutLocus {
station: u32,
index: u64,
},
#[error("rhapsody rank frame: {0}")]
Rank(#[source] KairosDecodeError),
#[error("rhapsody visible frame: {0}")]
Visible(#[source] HaveSetDecodeError),
}