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
use crate::typedef::NiftiType;
use quick_error::quick_error;
use std::io::Error as IOError;
quick_error! {
#[derive(Debug)]
pub enum NiftiError {
InvalidFormat {
display("Invalid NIfTI-1 file")
}
InconsistentDim(index: u8, value: u16) {
display("Inconsistent value `{}` in header field dim[{}] ({})", value, index, match index {
0 if *value > 7 => "must not be higher than 7",
_ => "must be positive"
})
}
OutOfBounds(coords: Vec<u16>) {
display("Out of bounds access to volume: {:?}", &coords[..])
}
AxisOutOfBounds(axis: u16) {
display("Out of bounds access to volume (axis {})", axis)
}
MissingVolumeFile(err: IOError) {
source(err)
display("Volume file not found")
}
NoVolumeData {
display("No volume data available")
}
IncorrectVolumeDimensionality(expected: u16, got: u16) {
display("Unexpected volume data dimensionality (expected {}, got {})", expected, got)
}
BadVolumeSize {
display("Bad volume size")
}
UnsupportedDataType(t: NiftiType) {
display("Unsupported data type")
}
Io(err: IOError) {
from()
source(err)
}
IncompatibleLength(got: usize, expected: usize) {
display("The buffer length ({}) and header dimensions ({} elements) are incompatible", got, expected)
}
IncorrectDescriptionLength(len: usize) {
display("Description length ({} bytes) is greater than 80 bytes.", len)
}
InvalidCode(typename: &'static str, code: i16) {
display("invalid code `{}` for header field {}", code, typename)
}
}
}
pub type Result<T> = ::std::result::Result<T, NiftiError>;