sluice/error.rs
1use cesu8::Cesu8DecodingError;
2
3/// All failure modes of the binary index parser.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum ParseError {
7 /// Wrapped I/O error from the underlying reader.
8 #[error("I/O error: {0}")]
9 Io(#[from] std::io::Error),
10
11 /// The index header declared an unsupported version byte.
12 #[error("unsupported index version: expected 0x01, got 0x{0:02X}")]
13 UnsupportedVersion(u8),
14
15 /// A field name or value failed Java Modified UTF-8 decoding.
16 #[error("modified UTF-8 decoding failed at field {context}: {source}")]
17 InvalidMutf8 {
18 /// Whether the failure happened on a field name or value.
19 context: &'static str,
20 /// Underlying cesu8 decode failure.
21 #[source]
22 source: Cesu8DecodingError,
23 },
24
25 /// Document field-count prefix was negative.
26 #[error("invalid field count: {0}")]
27 InvalidFieldCount(i32),
28
29 /// Field value length prefix was negative or over the safety cap.
30 #[error("invalid value length: {0}")]
31 InvalidValueLength(i32),
32
33 /// UINFO string had the wrong number of pipe-delimited segments.
34 #[error("malformed UINFO: {0:?}")]
35 MalformedUinfo(String),
36
37 /// EOF reached mid-way through a document's framing bytes.
38 #[error("unexpected EOF in middle of document after {bytes_into_doc} bytes")]
39 TruncatedDocument {
40 /// Number of bytes consumed into the truncated document.
41 bytes_into_doc: u64,
42 },
43}