1#![doc = include_str!("../README.md")]
2#![cfg_attr(not(feature = "std"), no_std)]
27#![forbid(unsafe_code)]
28
29extern crate alloc;
30extern crate static_assertions as sa;
31
32pub mod gba;
33pub use pkmn_core_types as core_types;
34pub use pkmn_strings as strings;
35
36use core::{fmt, result};
37
38#[cfg(feature = "std")]
39use std::io;
40
41#[cfg(not(feature = "std"))]
42use no_std_io2::io;
43
44#[derive(Debug)]
46pub enum SaveError {
47 IoError(io::Error),
48 Filesize,
49 CorruptSave,
50 NeverSaved,
51 OutOfBounds,
52 InvalidData,
53 NotFound,
54}
55
56impl fmt::Display for SaveError {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 match self {
59 SaveError::IoError(e) => e.fmt(f),
60 SaveError::Filesize => write!(f, "File size error."),
61 SaveError::CorruptSave => write!(f, "Save file is corrupt."),
62 SaveError::NeverSaved => write!(f, "No save data."),
63 SaveError::OutOfBounds => write!(f, "Out of bounds."),
64 SaveError::InvalidData => write!(f, "Invalid data."),
65 SaveError::NotFound => write!(f, "Not found."),
66 }
67 }
68}
69
70impl From<io::Error> for SaveError {
71 fn from(value: io::Error) -> Self {
72 SaveError::IoError(value)
73 }
74}
75
76pub type Result<T> = result::Result<T, SaveError>;