#![deny(missing_debug_implementations, missing_copy_implementations)]
#![warn(missing_docs, rustdoc::missing_crate_level_docs)]
#![doc = include_str!("../readme.md")]
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/208321371")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/208321371")]
mod errors;
mod games;
pub use crate::games::CncGame;
#[cfg(feature = "image")]
pub use image::{DynamicImage, Rgba, RgbaImage};
#[cfg(feature = "apng")]
pub use apng;
use std::{
error::Error,
fmt::{Display, Formatter},
};
pub type Result<T> = std::result::Result<T, Ra2Error>;
#[derive(Debug)]
pub enum Ra2Error {
IoError(std::io::Error),
CryptoError {
message: String,
},
InvalidFormat {
message: String,
},
EncodeError {
format: String,
message: String,
},
DecodeError {
format: String,
message: String,
},
FileNotFound(String),
OutOfBoundary {
limit: usize,
message: String,
},
}
impl Error for Ra2Error {}
impl Display for Ra2Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Ra2Error::IoError(e) => {
write!(f, "IO error: {}", e)
}
Ra2Error::CryptoError { message: e } => {
write!(f, "Crypto error:: {}", e)
}
Ra2Error::InvalidFormat { message: e } => {
write!(f, "Invalid file format: {}", e)
}
Ra2Error::FileNotFound(e) => {
write!(f, "File not found: {}", e)
}
Ra2Error::DecodeError { format, message } => {
write!(f, "Decode error: {}: {}", format, message)
}
Ra2Error::EncodeError { format, message } => {
write!(f, "Encode error: {}: {}", format, message)
}
Ra2Error::OutOfBoundary { limit, message } => {
write!(f, "Out of boundary {}: {}", limit, message)
}
}
}
}