plansolve 0.25.1

Official Rust client library for the PlanSolve optimization API.
Documentation
use thiserror::Error;

/// Convenience alias for results returned by this crate.
pub type Result<T> = std::result::Result<T, Error>;

/// Errors that can occur when using the PlanSolve client.
#[derive(Debug, Error)]
pub enum Error {
    /// The `PLANSOLVE_API_KEY` environment variable is not set.
    #[error("PLANSOLVE_API_KEY environment variable is not set")]
    MissingApiKey,

    /// The underlying HTTP transport failed.
    #[error("HTTP request failed: {0}")]
    Http(#[from] reqwest::Error),

    /// The API returned a non-2xx status code.
    #[error("API error: status {status}, body: {body}")]
    Api { status: u16, body: String },

    /// A job id was required but not provided.
    #[error("jobId was not provided")]
    MissingJobId,

    /// The solver did not finish within the allotted number of poll attempts.
    #[error("solver did not finish in the allotted time")]
    SolverTimeout,

    /// A score string could not be parsed.
    #[error("invalid score format: '{0}', expected format: 'Xhard/Ymedium/Zsoft'")]
    InvalidScore(String),
}