Skip to main content

yara_mapper/
error.rs

1/// Errors returned by the YARA mapper.
2#[derive(Debug)]
3#[non_exhaustive]
4pub enum YaraError {
5    /// Error opening or loading the YARA FM index.
6    IndexOpen(String),
7    /// Error building a YARA FM index from a FASTA file.
8    IndexBuild(String),
9    /// Error during read mapping.
10    Mapping(String),
11    /// Invalid input data (null bytes, length mismatch, etc.).
12    InvalidInput(String),
13}
14
15impl std::fmt::Display for YaraError {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        match self {
18            Self::IndexOpen(msg) => write!(f, "index open error: {msg}"),
19            Self::IndexBuild(msg) => write!(f, "index build error: {msg}"),
20            Self::Mapping(msg) => write!(f, "mapping error: {msg}"),
21            Self::InvalidInput(msg) => write!(f, "invalid input: {msg}"),
22        }
23    }
24}
25
26impl std::error::Error for YaraError {}