use std::io;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Ps2mcError {
#[error("io error: {0}")]
Io(#[from] io::Error),
#[error("superblock length invalid: expected {expected} bytes, got {actual}")]
InvalidSuperBlockLength { expected: usize, actual: usize },
#[error("not a valid superblock")]
InvalidSuperBlockMagic,
#[error("invalid page size {page_size}")]
InvalidPageSize { page_size: usize },
#[error("invalid pages-per-cluster value {pages_per_cluster}")]
InvalidPagesPerCluster { pages_per_cluster: usize },
#[error("unexpected end of file while reading {context}: expected {expected} bytes, got {actual}")]
UnexpectedEof {
context: &'static str,
expected: usize,
actual: usize,
},
#[error("fat index out of range for relative cluster {cluster}")]
InvalidFatIndex { cluster: u32 },
#[error("fat cycle detected at relative cluster {cluster}")]
FatCycle { cluster: u32 },
#[error("directory contains too many entries: {count} exceeds {max}")]
DirectoryTooLarge { count: usize, max: usize },
#[error("entry size {size} exceeds the supported maximum of {max} bytes")]
EntryTooLarge { size: u64, max: u64 },
#[error("invalid ascii in {field}")]
InvalidAsciiField { field: &'static str },
#[error("root directory entry is not a directory")]
InvalidRootEntry,
#[error("entry length invalid: expected {expected} bytes, got {actual}")]
InvalidEntryLength { expected: usize, actual: usize },
#[error("icon.sys length invalid: expected {expected} bytes, got {actual}")]
InvalidIconSysLength { expected: usize, actual: usize },
#[error("not a valid icon.sys payload")]
InvalidIconSysMagic,
#[error("not a valid icon payload")]
InvalidIconMagic,
#[error("not a valid icon animation header")]
InvalidAnimationHeader,
#[error("invalid compressed texture encoding")]
InvalidTextureEncoding,
#[error("decoded texture size mismatch: expected {expected} bytes, got {actual}")]
InvalidTextureSize { expected: usize, actual: usize },
#[error("can't find game {name}")]
SaveNotFound { name: String },
#[error("can't find icon file {name}")]
IconFileNotFound { name: String },
#[error("icon does not contain texture data")]
TextureUnavailable,
#[error("invalid write length: expected {expected} bytes, got {actual}")]
InvalidWriteLength { expected: usize, actual: usize },
#[error("ECC check failed; the ECC data in the spare area does not match.")]
EccMismatch,
#[error("invalid entry name: {name}")]
InvalidEntryName { name: String },
}