Expand description
§rick_and_morty
The rick_and_morty
crate provides a wrapper around rickandmortyapi.com
It exports all the basic entities available from the api:
Each module provides: get
, get_all
, get_multiple
for equvailent REST endpoints and matching structs.
The structs also have helper methods for getting related entities.
For example Character.origin()
method returns a Location
object.
All provided functions/methods are asynchronous:
§Examples:
- Getting all characters:
use rick_and_morty as rm;
async fn get_characters() -> () {
let c = rm::character::get_all().await;
match c {
Ok(res) => println!("{:?}", res),
Err(e) => println!("{:?}", e),
}
}
- Getting a single location:
use rick_and_morty as rm;
async fn get_location() -> () {
let c = rm::location::get(1).await;
match c {
Ok(res) => println!("{:?}", res),
Err(e) => println!("{:?}", e),
}
}
Modules§
character
mod provides struct and functions for querying charactersepisode
contains Struct and helper functions for episodes in the rick and morty api.location
module contains struct and functions for managing locations in the Rick And Morty Universe.
Structs§
- The Errors that may occur when processing a
Request
. - data about the page
Object
is a convenient wrapper for json objects returned from API for related entities.PageResponse
is a helper struct matching the shape of the returned json object when a call returned paginated results.