137 lines
4.6 KiB
Rust
Executable File
137 lines
4.6 KiB
Rust
Executable File
// Linter modifications
|
|
#![allow(unknown_lints)] // We use nightly lints, and sometimes the build server doesn't have them
|
|
#![allow(stable_features)] // We use nightly features, and there's sometimes a mismatch about which features are stable
|
|
#![allow(clippy::too_many_arguments, clippy::needless_range_loop)]
|
|
#![allow(clippy::not_unsafe_ptr_arg_deref)]
|
|
#![allow(clippy::borrowed_box)]
|
|
#![allow(incomplete_features)]
|
|
#![allow(ambiguous_glob_reexports)]
|
|
#![allow(hidden_glob_reexports)]
|
|
#![allow(clippy::arc_with_non_send_sync)]
|
|
// Documentation linters
|
|
#![deny(missing_docs)]
|
|
#![deny(clippy::missing_docs_in_private_items)]
|
|
// Linter rules to prevent panics
|
|
// Currently still a WIP to fix all of these
|
|
#![deny(clippy::unwrap_used)]
|
|
#![deny(clippy::expect_used)]
|
|
#![deny(clippy::indexing_slicing)]
|
|
#![deny(clippy::string_slice)]
|
|
#![deny(clippy::exit)]
|
|
#![deny(clippy::panic)]
|
|
#![deny(unused_must_use)]
|
|
// Features
|
|
#![feature(test)]
|
|
#![feature(const_option)]
|
|
#![feature(new_uninit)]
|
|
#![feature(get_mut_unchecked)]
|
|
#![feature(strict_provenance)]
|
|
#![feature(fn_traits)]
|
|
#![feature(unboxed_closures)]
|
|
#![feature(trait_upcasting)]
|
|
#![feature(lazy_cell)]
|
|
#![feature(try_trait_v2)]
|
|
|
|
//! PkmnLib
|
|
//! PkmnLib is a full featured implementation of Pokemon. while currently focused on implementing
|
|
//! generation 7, this library tries to offload generational differences such as move effects
|
|
//! to a scripting library.
|
|
//!
|
|
|
|
extern crate core;
|
|
|
|
#[macro_use]
|
|
extern crate enum_display_derive;
|
|
|
|
#[doc(hidden)]
|
|
pub use utils::*;
|
|
|
|
use crate::dynamic_data::ScriptCategory;
|
|
|
|
/// The defines module holds the core defines of the library
|
|
pub mod defines;
|
|
/// The dynamic data module holds data that can change during execution, and things that relate to
|
|
/// this. This includes things as Pokemon themselves, battles, etc.
|
|
pub mod dynamic_data;
|
|
/// The Foreign Function Interface allows for non Rust applications to call this library.
|
|
#[cfg(feature = "ffi")]
|
|
mod ffi;
|
|
/// Script implementations handles the different ways that dynamic scripts get loaded during battle.
|
|
pub mod script_implementations;
|
|
/// The static data module holds data that can be set once, and then never change. This includes
|
|
/// things such as data about Pokemon species, data about items, etc.
|
|
pub mod static_data;
|
|
/// The utils module includes misc utils that are used within PkmnLib
|
|
pub mod utils;
|
|
|
|
use crate::static_data::TypeIdentifier;
|
|
use thiserror::Error;
|
|
|
|
/// The PkmnError enum is the error type for PkmnLib. It is used to return common errors from functions
|
|
/// that can fail. For uncommon errors, anyhow is used.
|
|
#[derive(Error, Debug)]
|
|
pub enum PkmnError {
|
|
/// The given value was null
|
|
#[error("The given value was null")]
|
|
NullReference,
|
|
/// The given index is out of bounds for the given length of the array.
|
|
#[error("The given index {index} is out of bounds for the given len {len}")]
|
|
IndexOutOfBounds {
|
|
/// The index that was given
|
|
index: usize,
|
|
/// The length of the array
|
|
len: usize,
|
|
},
|
|
/// We tried to get a lock on a mutex, but the lock was poisoned. This means that another thread
|
|
/// panicked while holding the lock. This is a fatal error.
|
|
#[error("Unable to acquire a lock")]
|
|
UnableToAcquireLock,
|
|
/// Unable to get ability
|
|
#[error("Unable to get ability {ability}")]
|
|
InvalidAbilityName {
|
|
/// The ability that was requested
|
|
ability: StringKey,
|
|
},
|
|
/// Unable to get move
|
|
#[error("Unable to get move {move_name}")]
|
|
InvalidMoveName {
|
|
/// The move that was requested
|
|
move_name: StringKey,
|
|
},
|
|
/// Unable to get an item
|
|
#[error("Unable to get item {item}")]
|
|
InvalidItemName {
|
|
/// The item that was requested
|
|
item: StringKey,
|
|
},
|
|
/// Unable to get nature
|
|
#[error("Unable to get nature {nature}")]
|
|
InvalidNatureName {
|
|
/// The nature that was requested
|
|
nature: StringKey,
|
|
},
|
|
/// Unable to get species
|
|
#[error("Unable to get species {species}")]
|
|
InvalidSpeciesName {
|
|
/// The species that was requested
|
|
species: StringKey,
|
|
},
|
|
/// Unable to get form
|
|
#[error("Unable to get form {form} for species {species}")]
|
|
InvalidFormName {
|
|
/// The species for which the form was requested
|
|
species: StringKey,
|
|
/// The form that was requested
|
|
form: StringKey,
|
|
},
|
|
/// Unable to get type
|
|
#[error("Unable to get type {type_id}")]
|
|
InvalidTypeIdentifier {
|
|
/// The type that was requested
|
|
type_id: TypeIdentifier,
|
|
},
|
|
/// The given pointer is not a valid CString
|
|
#[error("The given pointer is not a valid CString")]
|
|
InvalidCString,
|
|
}
|