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
//! Error types for the `radsym` library.
/// Errors that can occur in `radsym` operations.
#[derive(thiserror::Error, Debug, Clone)]
#[non_exhaustive]
pub enum RadSymError {
/// Image dimensions are invalid (zero or incompatible).
#[error("invalid dimensions: width={width} height={height}")]
InvalidDimensions {
/// Image width.
width: usize,
/// Image height.
height: usize,
},
/// Provided buffer is too small for the given dimensions and stride.
#[error("buffer too small: needed={needed} got={got}")]
BufferTooSmall {
/// Minimum required buffer length.
needed: usize,
/// Actual buffer length.
got: usize,
},
/// Stride is smaller than the image width.
#[error("invalid stride: width={width} stride={stride}")]
InvalidStride {
/// Image width.
width: usize,
/// Provided stride.
stride: usize,
},
/// Configuration parameter is invalid.
#[error("invalid config: {reason}")]
InvalidConfig {
/// Description of the invalid parameter.
reason: &'static str,
},
/// The hypothesis is degenerate (e.g. zero radius, insufficient support).
#[error("degenerate hypothesis: {reason}")]
DegenerateHypothesis {
/// Description of the degeneracy.
reason: &'static str,
},
/// Refinement failed to converge or produced invalid results.
#[error("refinement failed: {reason}")]
RefinementFailed {
/// Description of the failure.
reason: &'static str,
},
/// Image I/O error (feature-gated: `image-io`).
#[cfg(feature = "image-io")]
#[error("image I/O error: {reason}")]
ImageIo {
/// Description of the I/O failure.
reason: String,
},
}
/// Convenience alias for `std::result::Result<T, RadSymError>`.
pub type Result<T> = std::result::Result<T, RadSymError>;