Crates.io | animality |
lib.rs | animality |
version | 1.0.0 |
source | src |
created_at | 2022-06-22 21:30:32.239122 |
updated_at | 2022-06-23 19:27:29.036299 |
description | API wrapper for the https://animality.xyz api |
homepage | |
repository | https://github.com/animality-xyz/animality.rs |
max_upload_size | |
id | 611157 |
size | 23,724 |
A simple Rust API wrapper that generates images & facts of any animal.
Add this to your Cargo.toml file's dependencies:
animality = "1.0.0"
extern crate animality;
use animality::{Animality, Animal};
fn main() {
let client = Animality::new("your token here");
// request with the `Animal` enum
let dog_image = client.image(Animal::Dog).unwrap();
let dog_fact = client.fact(Animal::Dog).unwrap();
// request from a string (case-insensitive)
let cat: Animal = "cat".parse().unwrap();
let cat_image = client.image(cat).unwrap();
let cat_fact = client.fact(cat).unwrap();
}
extern crate animality;
extern crate tokio;
use animality::{Animality, Animal, RequestError};
#[tokio::main]
async fn main() -> Result<(), RequestError> {
let client = Animality::new("your token here");
// request with the `Animal` enum
let dog_image = client.image_async(Animal::Dog).await?;
let dog_fact = client.fact_async(Animal::Dog).await?;
// request from a string (case-insensitive)
let cat: Animal = "cat".parse().unwrap();
let cat_image = client.image_async(cat).await?;
let cat_fact = client.fact_async(cat).await?;
Ok(())
}