#[derive(Debug)]
pub enum ScanError {
Timeout,
CannotReadFile(std::io::Error),
UnsupportedProcessScan,
UnknownProcess,
CannotListProcessRegions(std::io::Error),
CallbackAbort,
}
impl std::fmt::Display for ScanError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Timeout => write!(f, "timeout"),
Self::CannotReadFile(err) => write!(f, "cannot read file to scan: {err}"),
Self::UnsupportedProcessScan => {
write!(f, "process scanning is not implemented on this OS")
}
Self::UnknownProcess => {
write!(f, "unknown process")
}
Self::CannotListProcessRegions(error) => {
write!(f, "error listing memory regions of process: {error}")
}
Self::CallbackAbort => {
write!(f, "scan aborted in callback")
}
}
}
}
impl std::error::Error for ScanError {}
#[cfg(test)]
mod tests {
use super::*;
use crate::test_helpers::test_type_traits_non_clonable;
#[test]
fn test_types_traits() {
test_type_traits_non_clonable(ScanError::Timeout);
}
}