pub enum CspError {
Unsatisfiable,
BudgetExceeded,
InvalidInput {
detail: String,
},
Timeout,
}Expand description
Unified error family for Csp/Sudoku/Futoshiki operations exposed
across the PyO3 and wasm boundaries.
Deliberately flat (no nested Box<dyn Error> source chaining) — every
downstream binding needs to pattern-match this by value to pick an
exception class / HTTP status, and a flat enum is the cheapest thing
that supports that without reflection.
Variants§
Unsatisfiable
No solution exists under the current constraints/propagation.
Maps from the crate’s existing crate::Unsatisfiable marker (kept
as the internal propagation-layer type; this is the binding-facing
supertype).
BudgetExceeded
The search aborted after crate::SolveConfig::node_budget nodes;
any solutions returned are best-so-far, not verified optimal or
exhaustive. Distinct from Unsatisfiable — conflating the two was
Pass-1 finding R8/F12 (AssignmentBuilder and SudokuCSP both did
this).
InvalidInput
A caller-supplied argument was structurally invalid: an out-of-range position, a malformed numeric key, an unknown enum value, mismatched dimensions, etc. Carries a human-readable detail string (never leaked Rust-internal panic/debug detail — callers construct this variant explicitly, it is never built from a caught panic).
Timeout
A wall-clock deadline elapsed before the search produced a result.
Distinct from BudgetExceeded (a node-count budget, checked at the
same cadence but triggered by count not time). Forward-declared
for the wall-clock time_budget deferred item (synthesis-pass1 §3.1
N11) — the cooperative cancellation flag a caller’s own deadline
should set through the CancelToken, so the abort reaches the search
itself rather than only whatever coroutine or thread is awaiting it.
Implementations§
Source§impl CspError
impl CspError
Sourcepub const fn code(&self) -> &'static str
pub const fn code(&self) -> &'static str
Stable machine-readable discriminant. This exact string is what
py/errors.rs’s exception class names are derived from and what a
wasm CspJsError.code carries across that boundary — the single
vocabulary every layer of the taxonomy shares.
Sourcepub fn invalid_input(detail: impl Into<String>) -> Self
pub fn invalid_input(detail: impl Into<String>) -> Self
Convenience constructor — the one place format! call sites
collapse into, instead of each binding hand-rolling its own
PyValueError::new_err(format!(...)) / JsError::new(&format!(...)).
Trait Implementations§
Source§impl Error for CspError
impl Error for CspError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<AssignmentError> for CspError
AssignmentBuilder’s error family converts too, so py//wasm call
sites that touch the assignment/COP path get the same typed exceptions
as the Sudoku path for free. Note this conversion is itself evidence of
Pass-1 finding R8: Infeasible collapses onto Unsatisfiable here
because AssignmentError has no distinct budget-exhaustion variant yet
— fixing that is a separate, already ledgered item, not silently patched
over by this mapping.
impl From<AssignmentError> for CspError
AssignmentBuilder’s error family converts too, so py//wasm call
sites that touch the assignment/COP path get the same typed exceptions
as the Sudoku path for free. Note this conversion is itself evidence of
Pass-1 finding R8: Infeasible collapses onto Unsatisfiable here
because AssignmentError has no distinct budget-exhaustion variant yet
— fixing that is a separate, already ledgered item, not silently patched
over by this mapping.
Source§fn from(e: AssignmentError) -> Self
fn from(e: AssignmentError) -> Self
Source§impl From<Unsatisfiable> for CspError
The propagation layer’s existing marker type converts losslessly — every
current ?-using call site (Csp::propagate, Csp::propagate_with)
keeps compiling unchanged; only the bindings need to switch their
map_err target.
impl From<Unsatisfiable> for CspError
The propagation layer’s existing marker type converts losslessly — every
current ?-using call site (Csp::propagate, Csp::propagate_with)
keeps compiling unchanged; only the bindings need to switch their
map_err target.