Skip to main content

projective_grid/
error.rs

1//! Error types for grid tasks.
2
3use thiserror::Error;
4
5use crate::lattice::LatticeKind;
6
7/// Grid task that reported an error.
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
9#[non_exhaustive]
10pub enum GridTask {
11    /// Recover lattice labels from features.
12    Detection,
13    /// Check caller-supplied coordinate hypotheses.
14    Consistency,
15}
16
17/// Evidence kind supplied to a grid task.
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
19#[non_exhaustive]
20pub enum EvidenceKind {
21    /// Position-only point features.
22    Positions,
23    /// Features with one local axis.
24    Oriented1,
25    /// Features with two local axes.
26    Oriented2,
27    /// Features with three local axes.
28    Oriented3,
29}
30
31/// User-facing failure modes for projective-grid tasks.
32#[derive(Clone, Debug, Error, PartialEq, Eq)]
33#[non_exhaustive]
34pub enum GridError {
35    /// The requested task/lattice/evidence combination is intentionally not
36    /// implemented yet.
37    #[error("unsupported combination: task={task:?}, lattice={lattice:?}, evidence={evidence:?}")]
38    UnsupportedCombination {
39        /// Requested task.
40        task: GridTask,
41        /// Requested lattice family.
42        lattice: LatticeKind,
43        /// Supplied evidence kind.
44        evidence: EvidenceKind,
45    },
46    /// There is not enough evidence to run the requested task.
47    #[error("insufficient evidence")]
48    InsufficientEvidence,
49    /// Input slices disagree or contain duplicate/conflicting identifiers.
50    #[error("inconsistent input: {0}")]
51    InconsistentInput(String),
52    /// Geometry is degenerate, for example all model or image points are
53    /// collinear.
54    #[error("degenerate geometry")]
55    DegenerateGeometry,
56}
57
58/// Convenience result alias for this crate.
59pub type Result<T> = std::result::Result<T, GridError>;