1use std::fmt;
2
3#[derive(Debug)]
4pub enum Error {
5 MemoryRead(String),
7 Parse(String),
9 NotAvailable(String),
11 FileOperation(String),
13 Unsupported(String),
15 Other(String),
17}
18
19impl std::error::Error for Error {}
20
21impl fmt::Display for Error {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 match self {
24 Error::MemoryRead(msg) => write!(f, "Memory read error: {msg}"),
25 Error::Parse(msg) => write!(f, "Parse error: {msg}"),
26 Error::NotAvailable(msg) => write!(f, "Not available: {msg}"),
27 Error::FileOperation(msg) => write!(f, "File operation error: {msg}"),
28 Error::Unsupported(msg) => write!(f, "Unsupported operation: {msg}"),
29 Error::Other(msg) => write!(f, "Error: {msg}"),
30 }
31 }
32}
33
34impl From<std::io::Error> for Error {
35 fn from(err: std::io::Error) -> Self {
36 Error::FileOperation(err.to_string())
37 }
38}
39
40impl From<rosu_mem::error::ProcessError> for Error {
41 fn from(err: rosu_mem::error::ProcessError) -> Self {
42 Error::MemoryRead(err.to_string())
43 }
44}
45
46impl From<rosu_mem::error::ParseSignatureError> for Error {
47 fn from(err: rosu_mem::error::ParseSignatureError) -> Self {
48 Error::Parse(err.to_string())
49 }
50}
51
52pub type Result<T> = std::result::Result<T, Error>;