use thiserror::Error;
#[derive(Debug, Error)]
pub enum DryIceError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("invalid writer configuration: {0}")]
InvalidWriterConfiguration(&'static str),
#[error("invalid reader configuration: {0}")]
InvalidReaderConfiguration(&'static str),
#[error("sequence and quality lengths differ: sequence={sequence_len}, quality={quality_len}")]
MismatchedSequenceAndQualityLengths {
sequence_len: usize,
quality_len: usize,
},
#[error("record is missing required field: {field}")]
MissingRequiredField {
field: &'static str,
},
#[error("invalid sequence encoding input: {message}")]
InvalidSequenceInput {
message: &'static str,
},
#[error("invalid quality encoding input: {message}")]
InvalidQualityInput {
message: &'static str,
},
#[error("unsupported format version: {version}")]
UnsupportedFormatVersion {
version: u32,
},
#[error("invalid file magic bytes")]
InvalidMagic,
#[error("corrupt block header: {message}")]
CorruptBlockHeader {
message: &'static str,
},
#[error("corrupt block layout: {message}")]
CorruptBlockLayout {
message: &'static str,
},
#[error("corrupt record index at entry {entry}: {message}")]
CorruptRecordIndex {
entry: usize,
message: &'static str,
},
#[error("section `{section}` is missing but required by this block")]
MissingRequiredSection {
section: &'static str,
},
#[error("section `{section}` is present but not valid for this block")]
UnexpectedSection {
section: &'static str,
},
#[error("block checksum mismatch")]
ChecksumMismatch,
#[error("record {record_index} could not be decoded: {message}")]
RecordDecode {
record_index: usize,
message: &'static str,
},
#[error("record-key metadata does not match the configured key type")]
RecordKeyTypeMismatch,
#[error("record-key section is missing from this block")]
MissingRecordKeySection,
#[error("invalid record-key encoding: {message}")]
InvalidRecordKeyEncoding {
message: &'static str,
},
#[error(
"sequence codec mismatch: file contains tag {found:?}, but reader expects {expected:?}"
)]
SequenceCodecMismatch {
expected: [u8; 16],
found: [u8; 16],
},
#[error("quality codec mismatch: file contains tag {found:?}, but reader expects {expected:?}")]
QualityCodecMismatch {
expected: [u8; 16],
found: [u8; 16],
},
#[error("name codec mismatch: file contains tag {found:?}, but reader expects {expected:?}")]
NameCodecMismatch {
expected: [u8; 16],
found: [u8; 16],
},
#[error("{field} exceeds u32 range")]
SectionOverflow {
field: &'static str,
},
}