herolib-code 0.3.13

Code analysis and parsing utilities for Rust source files
Documentation
use std::path::PathBuf;
use thiserror::Error;

/// Errors that can occur during Rust building operations.
#[derive(Debug, Error)]
pub enum RustBuilderError {
    /// Cargo.toml not found starting from the given path
    #[error("Cargo.toml not found starting from '{path}'")]
    CargoTomlNotFound { path: PathBuf },

    /// Failed to parse Cargo.toml
    #[error("Failed to parse Cargo.toml at '{path}': {message}")]
    CargoTomlParseError { path: PathBuf, message: String },

    /// Build command failed
    #[error("Build failed with exit code {code}: {stderr}")]
    BuildFailed { code: i32, stderr: String },

    /// Binary not found in project
    #[error("Binary '{name}' not found in project")]
    BinaryNotFound { name: String },

    /// Artifact not found at expected path
    #[error("Artifact not found at expected path '{path}'")]
    ArtifactNotFound { path: PathBuf },

    /// Failed to copy artifact
    #[error("Failed to copy artifact: {message}")]
    CopyFailed { message: String },

    /// IO error
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    /// Path does not exist
    #[error("Path '{path}' does not exist")]
    PathNotFound { path: PathBuf },

    /// TOML parsing error
    #[error("TOML error: {0}")]
    TomlError(#[from] toml::de::Error),

    /// Invalid configuration
    #[error("Invalid configuration: {0}")]
    InvalidConfig(String),
}

pub type BuilderResult<T> = Result<T, RustBuilderError>;