SolverError

Enum SolverError 

Source
pub enum SolverError {
    NoSolution {
        context: Option<String>,
        variable_count: Option<usize>,
        constraint_count: Option<usize>,
    },
    Timeout {
        elapsed_seconds: Option<f64>,
        operation: Option<String>,
    },
    MemoryLimit {
        usage_mb: Option<usize>,
        limit_mb: Option<usize>,
    },
    InvalidConstraint {
        message: String,
        constraint_name: Option<String>,
        variables: Option<Vec<String>>,
    },
    ConflictingConstraints {
        constraint_names: Option<Vec<String>>,
        variables: Option<Vec<String>>,
        context: Option<String>,
    },
    InvalidDomain {
        message: String,
        variable_name: Option<String>,
        domain_info: Option<String>,
    },
    InvalidVariable {
        message: String,
        variable_id: Option<String>,
        expected: Option<String>,
    },
    InternalError {
        message: String,
        location: Option<String>,
        debug_info: Option<String>,
    },
}
Expand description

Simple error types for the CSP solver

This enum covers the basic failure modes that can occur during solving. Each error includes contextual information to help with debugging.

Variants§

§

NoSolution

No solution exists for the given constraints

Fields

§context: Option<String>

Additional context about why no solution was found

§variable_count: Option<usize>

Number of variables involved

§constraint_count: Option<usize>

Number of constraints checked

§

Timeout

Solving operation timed out

Fields

§elapsed_seconds: Option<f64>

How long the solver ran before timing out

§operation: Option<String>

What operation was being performed when timeout occurred

§

MemoryLimit

Memory limit was exceeded during solving

Fields

§usage_mb: Option<usize>

Approximate memory usage when limit was hit (in MB)

§limit_mb: Option<usize>

Memory limit that was exceeded (in MB)

§

InvalidConstraint

Invalid constraint was provided

Fields

§message: String

Description of what makes the constraint invalid

§constraint_name: Option<String>

Name or identifier of the problematic constraint

§variables: Option<Vec<String>>

Variables involved in the constraint

§

ConflictingConstraints

Conflicting constraints detected (unsatisfiable)

Fields

§constraint_names: Option<Vec<String>>

Names or descriptions of the conflicting constraints

§variables: Option<Vec<String>>

Variables involved in the conflict

§context: Option<String>

Additional context about the conflict

§

InvalidDomain

Invalid variable domain (e.g., min > max)

Fields

§message: String

Description of the domain problem

§variable_name: Option<String>

Name or identifier of the variable

§domain_info: Option<String>

The problematic domain bounds

§

InvalidVariable

Variable ID is invalid or out of bounds

Fields

§message: String

Description of what makes the variable invalid

§variable_id: Option<String>

Variable identifier that was invalid

§expected: Option<String>

Expected range or valid identifiers

§

InternalError

Internal solver error (should not happen in normal use)

Fields

§message: String

Description of the internal error

§location: Option<String>

File and line where the error occurred

§debug_info: Option<String>

Additional debugging context

Implementations§

Source§

impl SolverError

Source

pub fn no_solution() -> Self

Create a simple NoSolution error without context

Source

pub fn no_solution_with_context( context: impl Into<String>, var_count: usize, constraint_count: usize, ) -> Self

Create a NoSolution error with context

Source

pub fn timeout() -> Self

Create a simple Timeout error

Source

pub fn timeout_with_context( elapsed_seconds: f64, operation: impl Into<String>, ) -> Self

Create a Timeout error with context

Source

pub fn memory_limit() -> Self

Create a simple MemoryLimit error

Source

pub fn memory_limit_with_context(usage_mb: usize, limit_mb: usize) -> Self

Create a MemoryLimit error with usage info

Source

pub fn invalid_constraint(message: impl Into<String>) -> Self

Create an InvalidConstraint error with minimal context

Source

pub fn invalid_constraint_with_context( message: impl Into<String>, constraint_name: impl Into<String>, variables: Vec<String>, ) -> Self

Create an InvalidConstraint error with full context

Source

pub fn conflicting_constraints_with_names(constraint_names: Vec<String>) -> Self

Create a ConflictingConstraints error with constraint names

Source

pub fn conflicting_constraints_with_context( constraint_names: Vec<String>, variables: Vec<String>, context: impl Into<String>, ) -> Self

Create a ConflictingConstraints error with full context

Source

pub fn invalid_domain(message: impl Into<String>) -> Self

Create an InvalidDomain error with minimal context

Source

pub fn invalid_domain_with_context( message: impl Into<String>, variable_name: impl Into<String>, domain_info: impl Into<String>, ) -> Self

Create an InvalidDomain error with full context

Source

pub fn invalid_variable(message: impl Into<String>) -> Self

Create an InvalidVariable error with minimal context

Source

pub fn invalid_variable_with_context( message: impl Into<String>, variable_id: impl Into<String>, expected: impl Into<String>, ) -> Self

Create an InvalidVariable error with full context

Source

pub fn internal_error(message: impl Into<String>) -> Self

Create an InternalError with location context (typically called with file!() and line!())

Source

pub fn internal_error_with_context( message: impl Into<String>, file: &str, line: u32, debug_info: impl Into<String>, ) -> Self

Create an InternalError with full context

Trait Implementations§

Source§

impl Clone for SolverError

Source§

fn clone(&self) -> SolverError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SolverError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SolverError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for SolverError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ValidationError> for SolverError

Source§

fn from(validation_error: ValidationError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for SolverError

Source§

fn eq(&self, other: &SolverError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SolverError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.