plansolve 0.27.0

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 was still running when the client's poll budget ran out.
    #[error("solver still running after the client's poll budget elapsed (max_attempts × poll_interval); raise --max-attempts / --poll-interval, or bound the solve with `options.spentLimit` in the request so it converges sooner")]
    SolverTimeout,

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