1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//! Error types for the `dryice` crate.
use thiserror::Error;
/// Top-level error type for all `dryice` operations.
///
/// This enum is organized into broad categories: transport/IO errors,
/// configuration errors, input-record validity errors, format identity
/// and version errors, structural corruption errors, unsupported
/// feature errors, and integrity/decode failures.
#[derive(Debug, Error)]
pub enum DryIceError {
/// An underlying I/O error occurred.
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
/// The writer configuration is invalid.
#[error("invalid writer configuration: {0}")]
InvalidWriterConfiguration(&'static str),
/// The reader configuration is invalid.
#[error("invalid reader configuration: {0}")]
InvalidReaderConfiguration(&'static str),
/// Sequence and quality lengths do not match.
#[error("sequence and quality lengths differ: sequence={sequence_len}, quality={quality_len}")]
MismatchedSequenceAndQualityLengths {
/// Length of the sequence field.
sequence_len: usize,
/// Length of the quality field.
quality_len: usize,
},
/// A required record field is missing or empty.
#[error("record is missing required field: {field}")]
MissingRequiredField {
/// Name of the missing field.
field: &'static str,
},
/// Sequence data is not valid for the selected encoding.
#[error("invalid sequence encoding input: {message}")]
InvalidSequenceInput {
/// Description of the problem.
message: &'static str,
},
/// Quality data is not valid for the selected encoding.
#[error("invalid quality encoding input: {message}")]
InvalidQualityInput {
/// Description of the problem.
message: &'static str,
},
/// The file uses a format version this build does not support.
#[error("unsupported format version: {version}")]
UnsupportedFormatVersion {
/// The version number found in the file header.
version: u32,
},
/// The file does not begin with valid `dryice` magic bytes.
#[error("invalid file magic bytes")]
InvalidMagic,
/// A block header could not be parsed.
#[error("corrupt block header: {message}")]
CorruptBlockHeader {
/// Description of the corruption.
message: &'static str,
},
/// Block layout metadata is inconsistent or unreadable.
#[error("corrupt block layout: {message}")]
CorruptBlockLayout {
/// Description of the corruption.
message: &'static str,
},
/// A record index entry is corrupt or out of range.
#[error("corrupt record index at entry {entry}: {message}")]
CorruptRecordIndex {
/// Zero-based index of the problematic entry.
entry: usize,
/// Description of the corruption.
message: &'static str,
},
/// A section that should be present in this block is missing.
#[error("section `{section}` is missing but required by this block")]
MissingRequiredSection {
/// Name of the missing section.
section: &'static str,
},
/// A section is present but should not be for this block configuration.
#[error("section `{section}` is present but not valid for this block")]
UnexpectedSection {
/// Name of the unexpected section.
section: &'static str,
},
/// A block checksum did not match the computed value.
#[error("block checksum mismatch")]
ChecksumMismatch,
/// A record could not be decoded from block data.
#[error("record {record_index} could not be decoded: {message}")]
RecordDecode {
/// Zero-based index of the record within the block.
record_index: usize,
/// Description of the decode failure.
message: &'static str,
},
/// Record-key metadata in the block does not match the configured key type.
#[error("record-key metadata does not match the configured key type")]
RecordKeyTypeMismatch,
/// A record-key section is required but missing.
#[error("record-key section is missing from this block")]
MissingRecordKeySection,
/// A record-key encoding or decoding operation failed.
#[error("invalid record-key encoding: {message}")]
InvalidRecordKeyEncoding {
/// Description of the problem.
message: &'static str,
},
/// The block's sequence codec tag does not match the reader's configured codec.
#[error(
"sequence codec mismatch: file contains tag {found:?}, but reader expects {expected:?}"
)]
SequenceCodecMismatch {
/// The tag the reader expected.
expected: [u8; 16],
/// The tag found in the block header.
found: [u8; 16],
},
/// The block's quality codec tag does not match the reader's configured codec.
#[error("quality codec mismatch: file contains tag {found:?}, but reader expects {expected:?}")]
QualityCodecMismatch {
/// The tag the reader expected.
expected: [u8; 16],
/// The tag found in the block header.
found: [u8; 16],
},
/// The block's name codec tag does not match the reader's configured codec.
#[error("name codec mismatch: file contains tag {found:?}, but reader expects {expected:?}")]
NameCodecMismatch {
/// The tag the reader expected.
expected: [u8; 16],
/// The tag found in the block header.
found: [u8; 16],
},
/// A value exceeds the maximum representable size for the format.
#[error("{field} exceeds u32 range")]
SectionOverflow {
/// Which field or section overflowed.
field: &'static str,
},
}