[][src]Crate pokerust

pokerust

Rust wrapper for the pokeapi https://pokeapi.co/

Basic Usage

Get an object from an API by id

This example is not tested
use pokerust::{Berry, FromId};

fn main() {
    let berry = Berry::from_id(1).unwrap();
}

or by name

This example is not tested
use pokerust::{Berry, FromName};

fn main() {
    let berry = Berry::from_name("cheri").unwrap();
}

API responses are automatically cached.

You can also fetch the resource lists:

This example is not tested
use pokerust::{Item, Endpoint, List};

fn main() {
    let items = Item::list(5, 20).unwrap();  // ?offset=5&limit=20

    // get the lists referenced in the next and previous fields
    items.previous_list().unwrap();
    items.next_list().unwrap();

    // you can also just get the full list
    let all_items = Item::full_list().unwrap();
}

To get resources pointed to by (Named)APIResource, use get():

This example is not tested
let berry = Berry::from_name("cheri").unwrap();
let berry_item = berry.item.get().unwrap(); // berry_item is an Item

This can be chained:

This example is not tested
let marill = PokemonSpecies::from_name("marill").unwrap();
let sea_incense = marill.evolution_chain.get().unwrap().baby_trigger_item.unwrap().get().unwrap();

The location of the pokeapi used can be changed by setting the POKERUST_ENDPOINT environment variable. Defaults to the public instance at https://pokeapi.co/api/v2/. Please consult the pokeapi documentation and read the fair use policy before using the public API instance.

Structs

APIResource
APIResourceList
Ability
AbilityEffectChange
AbilityFlavorText
AbilityPokemon
AwesomeName
Berry
BerryFirmness
BerryFlavor
BerryFlavorMap
ChainLink
Characteristic
ContestComboDetail
ContestComboSets
ContestEffect
ContestName
ContestType
Description
ENDPOINT
Effect
EggGroup
Encounter
EncounterCondition
EncounterConditionValue
EncounterMethod
EncounterVersionDetails
EncouterMethodRate
EvolutionChain
EvolutionDetail
EvolutionTrigger
FlavorBerryMap
FlavorText
Gender
Generation
GenerationGameIndex
Genus
GrowthRate
GrowthRateExperienceLevel
Item
ItemAttribute
ItemCategory
ItemFlingEffect
ItemHolderPokemon
ItemHolderPokemonVersionDetail
ItemPocket
ItemSprites
Language
Location
LocationArea
LocationAreaEncounter
Machine
MachineVersionDetail
Move
MoveAilment
MoveBattleStyle
MoveBattleStylePreference
MoveCategory
MoveDamageClass
MoveFlavorText
MoveLearnMethod
MoveMetaData
MoveStatAffect
MoveStatAffectSets
MoveStatChange
MoveTarget
Name
NamedAPIResource
NamedAPIResourceList
Nature
NaturePokeathlonStatAffect
NaturePokeathlonStatAffectSets
NatureStatAffectSets
NatureStatChange
PalParkArea
PalParkEncounterArea
PalParkEncounterSpecies
PastMoveStatValues
PokeathlonStat
Pokedex
Pokemon
PokemonAbility
PokemonColor
PokemonEncouter
PokemonEntry
PokemonForm
PokemonFormSprites
PokemonHabitat
PokemonHeldItem
PokemonHeldItemVersion
PokemonMove
PokemonMoveVersion
PokemonShape
PokemonSpecies
PokemonSpeciesDexEntry
PokemonSpeciesGender
PokemonSpeciesVariety
PokemonSprites
PokemonStat
PokemonType
Region
Stat
SuperContestEffect
Type
TypePokemon
TypeRelations
VerboseEffect
Version
VersionEncounterDetail
VersionGameIndex
VersionGroup
VersionGroupFlavorText

Traits

Endpoint

Trait for API objects with an associated endpoint.

FromId
FromName
Id

Trait for API objects with an id.

List

Trait for lists of (Named)APIResources

Named

Trait for API objects with a name.