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
character
mod provides struct and functions for querying characters- episode
episode
contains Struct and helper functions for episodes in the rick and morty api.- location
location
module contains struct and functions for managing locations in the Rick And Morty Universe.
Structs§
- Error
- The Errors that may occur when processing a
Request
. - Info
- data about the page
- Object
Object
is a convenient wrapper for json objects returned from API for related entities.- Page
Response PageResponse
is a helper struct matching the shape of the returned json object when a call returned paginated results.