1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, HDF5Error>;
5
6#[derive(Debug, Error)]
8pub enum HDF5Error {
9 #[error("Not an HDF5 file: {hint}")]
11 InvalidSignature {
12 offset: u64,
14 hint: String,
16 },
17
18 #[error("Unsupported superblock version: {0}")]
20 UnsupportedSuperblockVersion(u8),
21
22 #[error("Unsupported object header version: {0}")]
24 UnsupportedObjectHeaderVersion(u8),
25
26 #[error("Unsupported data layout version: {0}")]
28 UnsupportedDataLayoutVersion(u8),
29
30 #[error("Unsupported datatype class: {0}")]
32 UnsupportedDatatypeClass(u8),
33
34 #[error("Unsupported filter pipeline version: {0}")]
36 UnsupportedFilterPipelineVersion(u8),
37
38 #[error("Unsupported chunk indexing type: {0}")]
40 UnsupportedChunkIndexingType(u8),
41
42 #[error("Unsupported B-tree version: {0}")]
44 UnsupportedBTreeVersion(u8),
45
46 #[error("Invalid B-tree signature: expected {expected}, got {got}")]
48 InvalidBTreeSignature {
49 expected: String,
51 got: String,
53 },
54
55 #[error("Unsupported heap version: {0}")]
57 UnsupportedHeapVersion(u8),
58
59 #[error("Invalid heap signature: expected {expected}, got {got}")]
61 InvalidHeapSignature {
62 expected: String,
64 got: String,
66 },
67
68 #[error("Group member not found: {0}")]
70 NotFound(String),
71
72 #[error("Expected group at path: {0}")]
74 NotAGroup(String),
75
76 #[error("Expected dataset at path: {0}")]
78 NotADataset(String),
79
80 #[error("Unexpected end of data: needed {needed} bytes, had {available}")]
82 UnexpectedEof {
83 needed: usize,
85 available: usize,
87 },
88
89 #[error("Undefined address encountered (unallocated storage)")]
91 UndefinedAddress,
92
93 #[error("Invalid object header signature: expected OHDR")]
95 InvalidObjectHeaderSignature,
96
97 #[error("Unsupported link type: {0}")]
99 UnsupportedLinkType(u8),
100
101 #[error("Unsupported message type: {0:#06x}")]
103 UnsupportedMessageType(u16),
104
105 #[error("I/O error: {0}")]
107 Io(#[from] std::io::Error),
108
109 #[error("{0}")]
111 General(String),
112
113 #[cfg(feature = "object_store")]
115 #[error("Object store error: {0}")]
116 ObjectStore(#[from] object_store::Error),
117
118 #[cfg(feature = "reqwest")]
120 #[error("HTTP error: {0}")]
121 Reqwest(#[from] reqwest::Error),
122}