vyre 0.3.0

GPU bytecode condition engine
Documentation
use thiserror::Error;

/// Result type for `vyre`.
pub type Result<T> = std::result::Result<T, Error>;

/// Errors produced by the bytecode engine.
#[derive(Debug, Error)]
pub enum Error {
    /// Bytecode failed validation checks.
    #[error("Bytecode validation failed: {message}. Fix: recompile the rule set and ensure the compiler only emits valid instructions.")]
    BytecodeValidation {
        /// Description of the validation failure.
        message: String,
    },
    /// GPU execution failed.
    #[error("GPU pipeline failed: {message}. Fix: verify wgpu is available and the compiled buffers fit the target adapter limits.")]
    Gpu {
        /// Description of the GPU failure.
        message: String,
    },
    /// Serialization/deserialization failed.
    #[error("Serialization failed: {message}. Fix: verify the index file is not truncated or corrupted.")]
    Serialization {
        /// Description of the serialization failure.
        message: String,
    },
    /// Invalid rule definition.
    #[error("Invalid rule: {rule} — {message}. Fix: check the rule definition and recompile.")]
    InvalidRule {
        /// Rule identifier.
        rule: String,
        /// Description of the problem.
        message: String,
    },
    /// Pattern compilation failed.
    #[error("Pattern compilation failed: {message}")]
    PatternCompilation {
        /// Description of the compilation failure.
        message: String,
    },
}

impl From<warpstate::Error> for Error {
    fn from(e: warpstate::Error) -> Self {
        Self::PatternCompilation {
            message: e.to_string(),
        }
    }
}