open_detect/errors.rs
1//! Error types for the open-detect crate.
2
3use thiserror::Error;
4
5/// A specialized `Result` type for open-detect operations.
6///
7/// This type is used throughout the crate for any operation that may produce an error.
8pub type Result<T> = std::result::Result<T, Error>;
9
10/// Errors that can occur during malware detection operations.
11///
12/// This enum wraps all possible error types that can be returned by the crate.
13///
14/// # Examples
15///
16/// ```
17/// use open_detect::{SigSet, Signature, Error};
18///
19/// let result = SigSet::from_signature(
20/// Signature("invalid yara rule".to_string())
21/// );
22/// assert!(result.is_err());
23/// ```
24#[derive(Debug, Error)]
25pub enum Error {
26 /// Error during YARA signature compilation.
27 ///
28 /// This occurs when a YARA rule has syntax errors or is otherwise invalid.
29 #[error("Signature compilation error: {0}")]
30 SignatureError(#[from] yara_x::errors::CompileError),
31
32 /// Error during YARA scanning operation.
33 ///
34 /// This occurs when the scanning process fails, typically due to resource
35 /// constraints or internal YARA errors.
36 #[error("Scanning error: {0}")]
37 ScanError(#[from] yara_x::errors::ScanError),
38
39 /// I/O error when reading files or directories.
40 ///
41 /// This occurs when files cannot be read, directories cannot be accessed,
42 /// or other filesystem operations fail.
43 #[error("I/O error: {0}")]
44 IoError(#[from] std::io::Error),
45}