primer3 0.1.0

Safe Rust bindings to the primer3 primer design library
Documentation
//! Error types for the primer3 crate.

use thiserror::Error;

/// Errors that can occur when using the primer3 library.
#[derive(Debug, Error)]
pub enum Primer3Error {
    /// The primer3 C library returned an error message.
    #[error("primer3 error: {0}")]
    Library(Box<str>),

    /// Failed to initialize thermodynamic parameters.
    #[error("failed to initialize thermodynamic parameters: {0}")]
    InitFailed(Box<str>),

    /// The input sequence is invalid (empty, contains non-DNA characters, etc.).
    #[error("invalid sequence: {0}")]
    InvalidSequence(Box<str>),

    /// The input sequence exceeds the maximum allowed length.
    #[error("sequence length {length} exceeds maximum {max} for {operation}")]
    SequenceTooLong { length: usize, max: usize, operation: &'static str },

    /// A design constraint is invalid (e.g., min > max).
    #[error("invalid setting: {0}")]
    InvalidSetting(String),

    /// Global errors from the primer design engine.
    #[error("primer design global error: {0}")]
    DesignGlobalError(Box<str>),

    /// Per-sequence errors from the primer design engine.
    #[error("primer design sequence error: {0}")]
    DesignSequenceError(Box<str>),
}

/// A `Result` type alias using [`Primer3Error`].
pub type Result<T> = std::result::Result<T, Primer3Error>;