1 unstable release

0.1.0 Dec 27, 2024

#163 in No standard library

Download history 159/week @ 2024-12-25

159 downloads per month
Used in 2 crates

MIT/Apache

79KB
1.5K SLoC

pkmn-core-types

Rust library with basic types for use with Pokémon games.

This includes types that represent Pokémon species, items, moves, abilities, natures, and types with values that correspond to the index numbers commonly used in the Pokémon games. These types support serde serialization and deserialization based on the English names for each.

Goals

  • No unsafe code.
  • no_std compatible.
  • Never panic.
  • Limited feature scope.
  • Minimal dependencies.

Cargo features

This library has a default but optional "std" feature for building with the Rust Standard Library. Build with default features disabled to support no_std environments. alloc is optional as well.

[depdendencies]
pkmn-core-types = {version = "0.1.0", default-features = false, features = ["alloc"]}

lib.rs:

Available types

Integer-wrapper types

All of these types are simple wrappers around a NonZero integer corresponding to an index value used by Pokémon games. They implement Display, Serialize, and Deserialize using English strings instead of the underlying integer value. For example, a PokemonSpecies containing the value 150 will be serialized as "Mewtwo", not "150".

When the meaning of values differs between generations of Pokémon games, separate types are offered for each relevant generation. The types without a number suffix are generally usable for all other generations that don't have their own specialization.

These types accept any nonzero value of their underlying primitive type, do not prevent creation of instances containing values that are invalid for any particular game, and offer functions that can be used to check whether its value is valid. Because they use NonZero, these types can be wrapped in an Option without increasing the size of the memory they occupy.

Enums

Several enums are defined in this library which represent a few types that are often used in Pokémon games and have a relatively small number of variants.

Dependencies

~0.3–1MB
~23K SLoC