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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
use errno::Errno;
use num_derive::FromPrimitive;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum CodesError {
#[error("ecCodes function returned a non-zero code")]
Internal(#[from] CodesInternal),
#[error("libc function returned an error with errno {0} and code {0}")]
LibcNonZero(i32, Errno),
#[error("Error occured while opening the file")]
CantOpenFile(#[from] std::io::Error),
#[error("No message have been found in the file")]
NoMessages,
#[error(transparent)]
CstrUTF8(#[from] std::str::Utf8Error),
#[error(transparent)]
NulChar(#[from] std::ffi::FromBytesWithNulError),
#[error("The key is missing in present message")]
MissingKey,
}
#[derive(Copy, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, Error, Debug, FromPrimitive)]
pub enum CodesInternal {
#[error("No error")]
CodesSuccess = 0,
#[error("End of resource reached")]
CodesEndOfFile = -1,
#[error("Internal error")]
CodesInternalError = -2,
#[error("Passed buffer is too small")]
CodesBufferTooSmall = -3,
#[error("Function not yet implemented")]
CodesNotImplemented = -4,
#[error("Missing 7777 at end of message")]
Codes7777NotFound = -5,
#[error("Passed array is too small")]
CodesArrayTooSmall = -6,
#[error("File not found")]
CodesFileNotFound = -7,
#[error("Code not found in code table")]
CodesCodeNotFoundInTable = -8,
#[error("Array size mismatch")]
CodesWrongArraySize = -9,
#[error("Key/value not found")]
CodesNotFound = -10,
#[error("Input output problem")]
CodesIoProblem = -11,
#[error("Message invalid")]
CodesInvalidMessage = -12,
#[error("Decoding invalid")]
CodesDecodingError = -13,
#[error("Encoding invalid")]
CodesEncodingError = -14,
#[error("Code cannot unpack because of string too small")]
CodesNoMoreInSet = -15,
#[error("Problem with calculation of geographic attributes")]
CodesGeocalculusProblem = -16,
#[error("Memory allocation error")]
CodesOutOfMemory = -17,
#[error("Value is read only")]
CodesReadOnly = -18,
#[error("Invalid argument")]
CodesInvalidArgument = -19,
#[error("Null handle")]
CodesNullHandle = -20,
#[error("Invalid section number")]
CodesInvalidSectionNumber = -21,
#[error("Value cannot be missing")]
CodesValueCannotBeMissing = -22,
#[error("Wrong message length")]
CodesWrongLength = -23,
#[error("Invalid key type")]
CodesInvalidType = -24,
#[error("Unable to set step")]
CodesWrongStep = -25,
#[error("Wrong units for step (step must be integer)")]
CodesWrongStepUnit = -26,
#[error("Invalid file id")]
CodesInvalidFile = -27,
#[error("Invalid grib id")]
CodesInvalidGrib = -28,
#[error("Invalid index id")]
CodesInvalidIndex = -29,
#[error("Invalid iterator id")]
CodesInvalidIterator = -30,
#[error("Invalid keys iterator id")]
CodesInvalidKeysIterator = -31,
#[error("Invalid nearest id")]
CodesInvalidNearest = -32,
#[error("Invalid order by")]
CodesInvalidOrderby = -33,
#[error("Missing a key from the fieldset")]
CodesMissingKey = -34,
#[error("The point is out of the grid area")]
CodesOutOfArea = -35,
#[error("Concept no match")]
CodesConceptNoMatch = -36,
#[error("Hash array no match")]
CodesHashArrayNoMatch = -37,
#[error("Definitions files not found")]
CodesNoDefinitions = -38,
#[error("Wrong type while packing")]
CodesWrongType = -39,
#[error("End of resource")]
CodesEnd = -40,
#[error("Unable to code a field without values")]
CodesNoValues = -41,
#[error("Grid description is wrong or inconsistent")]
CodesWrongGrid = -42,
#[error("End of index reached")]
CodesEndOfIndex = -43,
#[error("Null index")]
CodesNullIndex = -44,
#[error("End of resource reached when reading message")]
CodesPrematureEndOfFile = -45,
#[error("An internal array is too small")]
CodesInternalArrayTooSmall = -46,
#[error("Message is too large for the current architecture")]
CodesMessageTooLarge = -47,
#[error("Constant field")]
CodesConstantField = -48,
#[error("Switch unable to find a matching case")]
CodesSwitchNoMatch = -49,
#[error("Underflow")]
CodesUnderflow = -50,
#[error("Message malformed")]
CodesMessageMalformed = -51,
#[error("Index is corrupted")]
CodesCorruptedIndex = -52,
#[error("Invalid number of bits per value")]
CodesInvalidBpv = -53,
#[error("Edition of two messages is different")]
CodesDifferentEdition = -54,
#[error("Value is different")]
CodesValueDifferent = -55,
#[error("Invalid key value")]
CodesInvalidKeyValue = -56,
#[error("String is smaller than requested")]
CodesStringTooSmall = -57,
#[error("Wrong type conversion")]
CodesWrongConversion = -58,
#[error("Missing BUFR table entry for descriptor")]
CodesMissingBufrEntry = -59,
#[error("Null pointer")]
CodesNullPointer = -60,
#[error("Attribute is already present = cannot add")]
CodesAttributeClash = -61,
#[error("Too many attributes. Increase MAX_ACCESSOR_ATTRIBUTES")]
CodesTooManyAttributes = -62,
#[error("Attribute not found")]
CodesAttributeNotFound = -63,
#[error("Edition not supported")]
CodesUnsupportedEdition = -64,
#[error("Value out of coding range")]
CodesOutOfRange = -65,
#[error("Size of bitmap is incorrect")]
CodesWrongBitmapSize = -66,
#[error("Functionality not enabled")]
CodesFunctionalityNotEnabled = -67,
}